From 68b25a65f8a69a0bfcafd11bc4f0914aedfbe948 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Mon, 21 Sep 2020 23:26:53 +0100 Subject: [PATCH 1/5] solve --- week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js b/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js index 10b93ba..4689a6a 100644 --- a/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js +++ b/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js @@ -3,9 +3,10 @@ const personOne = { age: 34, favouriteFood: 'Spinach' } +const{name,age,favouiteFood}=personOne; function introduceYourself(___________________________) { console.log (`Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.`); } -introduceYourself(personOne); \ No newline at end of file +introduceYourself(personOne); From ef215d66aa95ccedbb1ff15f4d7fa1c2c222ff97 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Mon, 21 Sep 2020 23:40:37 +0100 Subject: [PATCH 2/5] Solved --- .../2-exercises/exercise-1/exercise-1.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js b/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js index 4689a6a..c9bfe98 100644 --- a/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js +++ b/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js @@ -1,12 +1,14 @@ const personOne = { - name: 'Popeye', - age: 34, - favouriteFood: 'Spinach' -} -const{name,age,favouiteFood}=personOne; + name: "Popeye", + age: 34, + favouriteFood: "Spinach", +}; +const { name, age, favouriteFood } = personOne; -function introduceYourself(___________________________) { - console.log (`Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.`); +function introduceYourself(name, age, favouriteFood) { + console.log( + `Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.` + ); } -introduceYourself(personOne); +introduceYourself(name, age, favouriteFood); From 0e5cf94dd31f747fa44d88c76786aee74b3c8c24 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Tue, 22 Sep 2020 11:46:27 +0100 Subject: [PATCH 3/5] solve task1 --- .../mandatory/2-exercises/exercise-2/exercise-2.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js index 0d3ade0..d1cf178 100644 --- a/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js +++ b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js @@ -9,3 +9,15 @@ let hogwarts = [ { firstName: "Minerva", lastName: "McGonagall", house: "Gryffindor", pet: null, occupation: "Teacher" }, { firstName: "Albus", lastName: "Dumbledore", house: "Gryffindor", pet: "Phoenix", occupation: "Teacher" } ] + +let GryffindorPeople = hogwarts.filter((element) => { + if (element.house === "Gryffindor") { + return true; + } +}); + +let [{ firstName, lastName }] = GryffindorPeople; + +GryffindorPeople.forEach((element) => { + console.log(element.firstName + " " + element.lastName); +}); From a489267685b29ef1fc8bc7f5f02330ea52a9893a Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Tue, 22 Sep 2020 11:56:58 +0100 Subject: [PATCH 4/5] solve task2 --- .../mandatory/2-exercises/exercise-2/exercise-2.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js index d1cf178..a5fc825 100644 --- a/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js +++ b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js @@ -21,3 +21,16 @@ let [{ firstName, lastName }] = GryffindorPeople; GryffindorPeople.forEach((element) => { console.log(element.firstName + " " + element.lastName); }); + +let teacherWithPet = hogwarts.filter((element) => { + if (element.pet !== null && element.occupation === "Teacher") { + return true; + } +}); + +let [{ firstName, lastName }] = teacherWithPet; + +teacherWithPet.forEach((element) => { + console.log(element.firstName + " " + element.lastName); +}); + From 9867f5ab32a1f2615e1026ab24a511b3a1b32d93 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Tue, 22 Sep 2020 14:06:56 +0100 Subject: [PATCH 5/5] Solved --- .../2-exercises/exercise-3/exercise-3.js | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.js b/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.js index b60d527..316440b 100644 --- a/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.js +++ b/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.js @@ -6,4 +6,39 @@ { itemName: "Hot Coffee", quantity: 2, unitPrice: 1.00}, { itemName: "Hash Brown", quantity: 4, unitPrice: 0.40} ] - \ No newline at end of file + + let order = [ + { itemName: "Hot cakes", quantity: 1, unitPrice: 2.29 }, + { itemName: "Apple Pie", quantity: 2, unitPrice: 1.39 }, + { itemName: "Egg McMuffin", quantity: 1, unitPrice: 2.8 }, + { itemName: "Sausage McMuffin", quantity: 1, unitPrice: 3.0 }, + { itemName: "Hot Coffee", quantity: 2, unitPrice: 1.0 }, + { itemName: "Hash Brown", quantity: 4, unitPrice: 0.4 }, +]; + +let total = 0; +console.log("QTY ITEM TOTAL"); +order.forEach((element) => { + console.log( + element.quantity + + " " + + element.itemName + + " " + + element.quantity * element.unitPrice + ); + total += element.quantity * element.unitPrice; +}); +console.log(" Total: " + total); + +/* +function printReceipt(order) { + let oneOrderKeys = Object.keys(order[0]); + let orderKeys = oneOrderKeys.map(changeCase); + + console.log(orderKeys); +} +function changeCase(word) { + return word.toUpperCase(); +} +printReceipt(order); +*/