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


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


Expand All @@ -31,8 +31,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"}
*/


console.log(createMenuItem("pizza",5,"lunch"));

/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
You're having a lunch special! 25% off for teachers and students, 10% off for everyone else. Add a method to the burger object below that automatically calculates price depending on the string received as a parameter.
Expand All @@ -51,8 +50,17 @@ const burger = {
name: "Burger",
price: 18,
category: "Lunch",

discount: function (arg) {
if (arg === "teacher" || arg === "student") {
this.price = 18 - (18 * .25);
} else {
this.price = 18 - (18 * .10);
}
return this.price;
}
}
console.log(burger.discount("teacher"));
console.log(burger.discount("public"));



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



Expand All @@ -80,7 +89,8 @@ Reyna's feedback is missing! Use what you know to do the following: (no function
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(reviews[7].feedback);


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


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


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


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


Expand All @@ -131,8 +142,8 @@ 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}`
}


Expand All @@ -153,9 +164,18 @@ Use the getReviewsByRating function below to do the following:
]
*/

function getReviewByRating(/* code here */) {
/* code here */
function getReviewByRating(array, rating) {
const newArray =[];
for (let i = 0; i < array.length; i++)
{
if (Math.floor(array[i].rating) === Math.floor(rating))
{
newArray.push(array[i]);
}
}
return newArray;
}
console.log(getReviewByRating(reviews, 4));


/* 💪💪💪💪💪💪💪💪💪💪 STRETCH 2: 💪💪💪💪💪💪💪💪💪💪
Expand All @@ -171,9 +191,19 @@ Use the getLongReviews function below to do the following:
]
*/

function getLongReviews(/* code here */) {
/* code here */
function getLongReviews(array) {
const longReviews = [];
for (let i = 0; i < array.length; i++)
{
if (array[i].feedback.split(" ").length > 15)
{
longReviews.push(array[i]);
}
}
return longReviews;
}

console.log(getLongReviews(reviews));


/* 💪💪💪💪💪💪💪💪💪💪 STRETCH 3: 💪💪💪💪💪💪💪💪💪💪
Expand All @@ -193,13 +223,6 @@ Use the carMaker function below to do the following:
It would return 110 because it was created with 10 as the odometer and we added 100 to it with the drive method
*/


function carMaker(/* code here */) {
/* code here */

}


/* 🛑🛑🛑🛑🛑 Please do not modify anything below this line 🛑🛑🛑🛑🛑 */
function foo(){
console.log('its working');
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.