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
47 changes: 34 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ The function should:
*/


function createMenuItem(/*Your code here*/){
/*Your code here*/
function createMenuItem(newItem,price,cat){
const lunchItem = {};
lunchItem.name = newItem
lunchItem.price = price
lunchItem.category = cat
return(lunchItem)
}


Expand All @@ -32,6 +36,7 @@ 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"}
*/

createMenuItem('fries',2,'lunch')


/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -51,11 +56,19 @@ const burger = {
name: "Burger",
price: 18,
category: "Lunch",

discount(role){
if(role === 'teacher' || role === 'student'){
return(this.price - this.price * .25)
}
else{
return(this.price - this.price * .10)
}
}
}




///////////////Reviews (MVP)///////////////////
const reviews = [
{name: "Daniela", rating: 5, feedback:"Beautiful atmosphere and wonderful vegan options!"},
Expand All @@ -72,15 +85,15 @@ 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): 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Reyna's feedback is missing! Use what you know to do the following: (no function needed)
1. Add this feedback to Reyna's rating - "this place is chill with really cool people, great for getting work done on weekdays"
2. log the reviews array to the console to check your work
*/

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


/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -95,8 +108,9 @@ Use the addReview function below to do the following:
*/


function addReview(/*Your Code Here */){
/*Your Code Here */
function addReview(ar,nm,rt,rev){
ar.push({name: nm ,rating: rt ,feedback: rev});
return(ar)
}


Expand All @@ -112,8 +126,9 @@ Use the getReviewByIndex function below to do the following:
*/


function getReviewByIndex(/*Your code here*/) {
/*Your code here*/
function getReviewByIndex(ar,ind) {
const reviewChoice = ar[ind]
return(`${ar[ind].name} gave the restaurant a ${ar[ind].rating} star review, and their feedback was: ${ar[ind].feedback}`)
}


Expand All @@ -131,8 +146,8 @@ Use the getLastReview function below to do the following:
*/


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


Expand All @@ -153,8 +168,14 @@ Use the getReviewsByRating function below to do the following:
]
*/

function getReviewByRating(/* code here */) {
/* code here */
function getReviewByRating(ar,ra) {
let reviewList = {}
for(i=0;i<ar.length;i++){
if(ar[i].rating === ra){
reviewList.push(ra[i])
}
return(reviewList)
}
}


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.