From fdfad14fbd7836ed41b5473f83107acfd530fd59 Mon Sep 17 00:00:00 2001 From: Texi Schaeffer Date: Mon, 29 Aug 2022 17:12:21 -0500 Subject: [PATCH 1/4] completed through to task 2 --- index.js | 20 ++++++++++++++------ package-lock.json | 4 ++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 833600e1..81f966e9 100644 --- a/index.js +++ b/index.js @@ -16,10 +16,10 @@ 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): πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ @@ -32,7 +32,9 @@ 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('pancakes', 10, 'breakfast')); +console.log(createMenuItem('cheeseburger', 9, 'Lunch')); +console.log(createMenuItem('steak', 20, 'dinner')); /* πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ 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. @@ -51,9 +53,15 @@ const burger = { name: "Burger", price: 18, category: "Lunch", - + discount: function(person){ + if(person === 'teacher' || person === 'student'){ + return this.price * 0.75; + }else{ + return this.price * 0.9; + } + } } - +console.log(burger.discount('teacher')); ///////////////Reviews (MVP)/////////////////// diff --git a/package-lock.json b/package-lock.json index 48103f21..0f48f45e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "codegraded-project-js", - "version": "0.0.8", + "version": "0.0.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "codegraded-project-js", - "version": "0.0.8", + "version": "0.0.9", "devDependencies": { "@babel/core": "7.17.5", "@babel/plugin-transform-runtime": "7.17.0", From e7299afb9f6fd65caf4e9b3281fa08fb5db9a28a Mon Sep 17 00:00:00 2001 From: Texi Schaeffer Date: Mon, 29 Aug 2022 17:14:25 -0500 Subject: [PATCH 2/4] completed through to task 3 --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 81f966e9..61b897ff 100644 --- a/index.js +++ b/index.js @@ -81,7 +81,7 @@ 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) From 1d3985d71aa3c8176519e1a0abe35d9f21080772 Mon Sep 17 00:00:00 2001 From: Texi Schaeffer Date: Mon, 29 Aug 2022 17:23:50 -0500 Subject: [PATCH 3/4] completed task 7 --- index.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 61b897ff..47dd1a54 100644 --- a/index.js +++ b/index.js @@ -89,7 +89,8 @@ 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].feedback = "this place is chill with really cool people, great for getting work done on weekdays"; +console.log(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. @@ -120,10 +121,10 @@ 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}`; } - +console.log(getReviewByIndex(reviews, 3)); /* πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ Task 7: πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ @@ -139,10 +140,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(getLastReview(reviews)); ///////////////πŸ”β˜•οΈπŸ½ STRETCHπŸ”β˜•οΈπŸ½//////////////////// From a6247802d24ebe3a4cd0abdb64169b450db3bcd5 Mon Sep 17 00:00:00 2001 From: Texi Schaeffer Date: Mon, 29 Aug 2022 17:28:57 -0500 Subject: [PATCH 4/4] completed mvp --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 47dd1a54..f5fb3604 100644 --- a/index.js +++ b/index.js @@ -104,11 +104,12 @@ 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; } - +console.log(addReview(reviews, 'Texi', 2, 'The steak was overcooked!')); /* πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ Task 6: πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ Write a function to return a review based on the index of the review in the array.