Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 35 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ The function should:
*/


function createMenuItem(/*Your code here*/){
/*Your code here*/
}
function createMenuItem(name, price, category){
return{name, price, category};

}
console.log(createMenuItem('tacos', 8, 'Lunch'));


/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 1b (not auto-tested): 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -32,6 +33,10 @@ Test your createMenuItems function by doing the following:
For example: createMenuItem("pizza",5,"lunch") would return this as the object: {name:"Pizza",price:5,category:"lunch"}
*/

console.log(createMenuItem(createMenuItem('cheeseBurger', 5, 'Lunch')));
console.log(createMenuItem(createMenuItem('panCakes', 3, 'Breakfast')));
console.log(createMenuItem(createMenuItem('mashPotatoes', 7, 'Dinner')));



/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -50,11 +55,20 @@ Using the burger object below do the following:
const burger = {
name: "Burger",
price: 18,
category: "Lunch",

category: "Lunch",

discount: function(person){
if(person === 'teacher' || person === 'student'){
return this.price - (this.price * 0.25);
}else if (person === 'public'){
return this.price - (this.price * 0.10);
}
}
}


console.log(burger.discount('teacher'));
console.log(burger.discount('student'));
console.log(burger.discount('public'));

///////////////Reviews (MVP)///////////////////
const reviews = [
Expand All @@ -72,7 +86,7 @@ const reviews = [
Using the reviews array above:
1. log only Julius' feedback to the console - no function needed
*/

console.log(reviews[5].feedback);


/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 (not auto-tested): 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -81,6 +95,9 @@ Reyna's feedback is missing! Use what you know to do the following: (no function
2. log the reviews array to the console to check your work
*/

reviews[7] = "this place is chill with really cool people, great for getting work done on weekdays"




/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -94,10 +111,11 @@ Use the addReview function below to do the following:
4. Return the updated array
*/


function addReview(/*Your Code Here */){
/*Your Code Here */
function addReview(reviews, name, rating, feedback){
reviews.push({name: name, rating: rating, feedback: feedback});
return reviews
}
console.log(addReview(reviews, 'Anaiz', 8, 'love the food'));



Expand All @@ -111,11 +129,12 @@ Use the getReviewByIndex function below to do the following:
For example: getReviewByIndex(reviews,0) would return: "Daniela gave the restaurant a 5 star review, and their feedback was: Beautiful atmosphere and wonderful vegan options!"
*/


function getReviewByIndex(/*Your code here*/) {
/*Your code here*/
function getReviewByIndex(array, number) {
return `${array[number].name} gave the restaurant a ${array[number].rating} star review, and their feedback was: ${array[number].feedback}`;
}

console.log(getReviewByIndex(reviews, 5));



/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -131,11 +150,11 @@ Use the getLastReview function below to do the following:
*/


function getLastReview(/*Your code here*/) {
/*Your code here*/
function getLastReview(array) {
return`${array[array.length -1].name} gave the restaurant a ${array[array.length -1].rating} star review, and their feedback was: ${array[array.length -1].feedback}`;
}


console.log(getLastReview(reviews));

///////////////🍔☕️🍽 STRETCH🍔☕️🍽////////////////////

Expand Down
Loading