From 592386d82ccfd0d171b4e6077ab37a34e7132884 Mon Sep 17 00:00:00 2001 From: mrafeie Date: Wed, 16 Sep 2026 14:37:10 +0100 Subject: [PATCH 1/3] Update introduceYourself function to use destructuring --- Sprint-1/destructuring/exercise-1/exercise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/destructuring/exercise-1/exercise.js b/Sprint-1/destructuring/exercise-1/exercise.js index 1ff2ac5cf..90eb47951 100644 --- a/Sprint-1/destructuring/exercise-1/exercise.js +++ b/Sprint-1/destructuring/exercise-1/exercise.js @@ -6,7 +6,7 @@ const personOne = { // Update the parameter to this function to make it work. // Don't change anything else. -function introduceYourself(___________________________) { +function introduceYourself({name, age, favouriteFood}) { console.log( `Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.` ); From 1ccf3d444a39bd867d8af91a0775b931b6af3531 Mon Sep 17 00:00:00 2001 From: mrafeie Date: Wed, 16 Sep 2026 14:40:45 +0100 Subject: [PATCH 2/3] Add functions to display names based on criteria --- Sprint-1/destructuring/exercise-2/exercise.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Sprint-1/destructuring/exercise-2/exercise.js b/Sprint-1/destructuring/exercise-2/exercise.js index e11b75eb9..6ee8e0139 100644 --- a/Sprint-1/destructuring/exercise-2/exercise.js +++ b/Sprint-1/destructuring/exercise-2/exercise.js @@ -70,3 +70,23 @@ let hogwarts = [ occupation: "Teacher", }, ]; +//task 1 +function displayNames(names){ + for (let person of names) { + const { firstName, lastName, house } = person; + if (house === "Gryffindor") { + console.log(`${firstName} ${lastName}`); + } + } +} +//task 2 +function displayTeacherNames(names){ + for (let person of names) { + const { firstName, lastName, pet, occupation } = person; + if (occupation === "Teacher" && pet !== null) { + console.log(`${firstName} ${lastName}`); + } + } +} +displayNames(hogwarts); +displayTeacherNames(hogwarts); From 9244c8505bbe65c06894a417da1f4e38899c1c6e Mon Sep 17 00:00:00 2001 From: mrafeie Date: Wed, 16 Sep 2026 14:44:19 +0100 Subject: [PATCH 3/3] Implement order total calculation and display Added logging for order details and total calculation. --- 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..d5a8bf8a3 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 total = 0; +for(let item of order){ + const { itemName, quantity, unitPricePence } = item; + const itemTotal = quantity * unitPricePence; + total += itemTotal; + console.log(`${quantity.toString().padEnd(8)}${itemName.padEnd(20)}${(itemTotal / 100).toFixed(2)}`); +}