Skip to content

Finished #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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: 30 additions & 17 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('task 1 a', createMenuItem('tacos', 8, 'Lunch'));


/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 1b (not auto-tested): 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -31,6 +32,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('task 1b', createMenuItem('pizza', 5, 'lunch'));
console.log('task 1b', createMenuItem('hotdog', 4, 'lunch'));
console.log('task 1b', createMenuItem('french fries', 2, 'lunch'));




Expand All @@ -51,9 +56,15 @@ const burger = {
name: "Burger",
price: 18,
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('task 2',burger.discount('teacher'));


///////////////Reviews (MVP)///////////////////
Expand All @@ -65,23 +76,23 @@ const reviews = [
{name: "Brett", rating: 3, feedback: "great selection of snacks and a nice cafe area to get work done during the day."},
{name: "Julius", rating: 2, feedback: "I was largely unimpressed by this venue. Nothing special on the menu and too expensive. The atmosphere is polarizing, and not for me, but I think some would like it." },
{name: "Lauren", rating: 4, feedback: "Absolutely love that they have karaoke Fridays! Food and drink selection is okay."},
{name: "Reyna", rating: 3.5, feedback: ""},
{name: "Reyna", rating: 3.5, feedback: ""},
]

/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 (not auto-tested): 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Using the reviews array above:
1. log only Julius' feedback to the console - no function needed
*/

console.log('task 3:', 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";
console.log('task 4', reviews);

/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Write a function that creates an object with name, rating, feedback, add the new review to the end of an array and returns the resulting array.
Expand All @@ -95,10 +106,12 @@ Use the addReview function below to do the following:
*/


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,'Jared', 2, 'lame food'));


/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -112,8 +125,8 @@ Use the getReviewByIndex function below to do the following:
*/


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}`;
}


Expand All @@ -131,10 +144,10 @@ 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(`task 7:`, getLastReview(reviews));


///////////////🍔☕️🍽 STRETCH🍔☕️🍽////////////////////
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.