From 3ddc643e70e91aff364915cde36e4e32a2d411f2 Mon Sep 17 00:00:00 2001 From: Ebrahim_Moqbel Date: Mon, 14 Sep 2026 15:53:33 +0100 Subject: [PATCH 1/5] completed exercise 1 --- Sprint-1/destructuring/exercise-1/exercise.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-1/destructuring/exercise-1/exercise.js b/Sprint-1/destructuring/exercise-1/exercise.js index 1ff2ac5cf..ae07cd873 100644 --- a/Sprint-1/destructuring/exercise-1/exercise.js +++ b/Sprint-1/destructuring/exercise-1/exercise.js @@ -5,11 +5,12 @@ const personOne = { }; // Update the parameter to this function to make it work. +let { name, age, favouriteFood } = personOne; // Don't change anything else. -function introduceYourself(___________________________) { +function introduceYourself(personOne) { console.log( `Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.` ); } -introduceYourself(personOne); +console.log(introduceYourself(personOne)); From c6b8b52ad1829ab5fcd9f2c5d9f4d31afe82bd65 Mon Sep 17 00:00:00 2001 From: Ebrahim_Moqbel Date: Mon, 14 Sep 2026 16:11:54 +0100 Subject: [PATCH 2/5] implemented a function that display the names of the people alocated to Gryffindor house --- Sprint-1/destructuring/exercise-2/exercise.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-1/destructuring/exercise-2/exercise.js b/Sprint-1/destructuring/exercise-2/exercise.js index e11b75eb9..73bf75f11 100644 --- a/Sprint-1/destructuring/exercise-2/exercise.js +++ b/Sprint-1/destructuring/exercise-2/exercise.js @@ -70,3 +70,10 @@ let hogwarts = [ occupation: "Teacher", }, ]; + +// display the names of the people who belong to the Gryffindor house +hogwarts.forEach(({ firstName, lastName, house }) => { + if (house === "Gryffindor") { + console.log(`${firstName} ${lastName}`); + } +}); From b32077434dc8c1c265ab4f7b7f169b4b379571ad Mon Sep 17 00:00:00 2001 From: Ebrahim_Moqbel Date: Mon, 14 Sep 2026 16:21:41 +0100 Subject: [PATCH 3/5] display the names of the teschers how have pets --- Sprint-1/destructuring/exercise-2/exercise.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-1/destructuring/exercise-2/exercise.js b/Sprint-1/destructuring/exercise-2/exercise.js index 73bf75f11..00257919f 100644 --- a/Sprint-1/destructuring/exercise-2/exercise.js +++ b/Sprint-1/destructuring/exercise-2/exercise.js @@ -77,3 +77,11 @@ hogwarts.forEach(({ firstName, lastName, house }) => { console.log(`${firstName} ${lastName}`); } }); + +// display the names of the teachers who have pets + +hogwarts.forEach(({ firstName, lastName, occupation, pet }) => { + if (occupation === "teacher" && pet !== null) { + console.log(`${firstName} ${lastName}`); + } +}); From 2a0080c69fd24ccf07c203888835c6789f375db0 Mon Sep 17 00:00:00 2001 From: Ebrahim_Moqbel Date: Mon, 14 Sep 2026 16:22:19 +0100 Subject: [PATCH 4/5] fixed a typo --- Sprint-1/destructuring/exercise-2/exercise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/destructuring/exercise-2/exercise.js b/Sprint-1/destructuring/exercise-2/exercise.js index 00257919f..53468171f 100644 --- a/Sprint-1/destructuring/exercise-2/exercise.js +++ b/Sprint-1/destructuring/exercise-2/exercise.js @@ -81,7 +81,7 @@ hogwarts.forEach(({ firstName, lastName, house }) => { // display the names of the teachers who have pets hogwarts.forEach(({ firstName, lastName, occupation, pet }) => { - if (occupation === "teacher" && pet !== null) { + if (occupation === "Teacher" && pet !== null) { console.log(`${firstName} ${lastName}`); } }); From d0872d97957550b69aac003d90a9c608c82b4eef Mon Sep 17 00:00:00 2001 From: Ebrahim_Moqbel Date: Mon, 14 Sep 2026 16:42:24 +0100 Subject: [PATCH 5/5] implemented a function that display the items and calculate the total price for a provided order --- Sprint-1/destructuring/exercise-3/exercise.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-1/destructuring/exercise-3/exercise.js b/Sprint-1/destructuring/exercise-3/exercise.js index b3a36f4e4..11dd6defd 100644 --- a/Sprint-1/destructuring/exercise-3/exercise.js +++ b/Sprint-1/destructuring/exercise-3/exercise.js @@ -6,3 +6,11 @@ let order = [ { itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 }, { itemName: "Hash Brown", quantity: 4, unitPricePence: 40 }, ]; +console.log("QTY ITEM TOTAL"); +let basketTotal = 0; +order.forEach(({ itemName, quantity, unitPricePence }) => { + itemTotal = quantity * unitPricePence; + basketTotal += itemTotal; + console.log(`${quantity} ${itemName} ${itemTotal}`); +}); +console.log(`\nTotal: ${(basketTotal / 100).toFixed(2)} `);