From c436469c8eb78c3e3ed7a4f1dabcb460cf66ec53 Mon Sep 17 00:00:00 2001 From: Rahana Suleiman Date: Wed, 25 Nov 2026 22:23:35 +0000 Subject: [PATCH 1/3] Fix function parameter to enable destructuring in introduceYourself --- 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..d86bc7bf8 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 7dfa6813c7cbf23eec0371b175b40ccdd848514f Mon Sep 17 00:00:00 2001 From: Rahana Suleiman Date: Wed, 25 Nov 2026 22:28:07 +0000 Subject: [PATCH 2/3] Add tasks to display Gryffindor members and teachers with pets --- Sprint-1/destructuring/exercise-2/exercise.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Sprint-1/destructuring/exercise-2/exercise.js b/Sprint-1/destructuring/exercise-2/exercise.js index e11b75eb9..6ae5a38c9 100644 --- a/Sprint-1/destructuring/exercise-2/exercise.js +++ b/Sprint-1/destructuring/exercise-2/exercise.js @@ -70,3 +70,17 @@ let hogwarts = [ occupation: "Teacher", }, ]; + +// Task 1: Gryffindor members +for (const { firstName, lastName, house } of hogwarts) { + if (house === "Gryffindor") { + console.log(`${firstName} ${lastName}`); + } +} + +// Task 2: Teachers with pets +for (const { firstName, lastName, occupation, pet } of hogwarts) { + if (occupation === "Teacher" && pet !== null) { + console.log(`${firstName} ${lastName}`); + } +} From eef58e7c4d5111222c4b3bb74510ef042bb4f5fb Mon Sep 17 00:00:00 2001 From: Rahana Suleiman Date: Wed, 25 Nov 2026 22:30:17 +0000 Subject: [PATCH 3/3] Refactor order processing to calculate and display total prices --- Sprint-1/destructuring/exercise-3/exercise.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Sprint-1/destructuring/exercise-3/exercise.js b/Sprint-1/destructuring/exercise-3/exercise.js index b3a36f4e4..eaad4a4b2 100644 --- a/Sprint-1/destructuring/exercise-3/exercise.js +++ b/Sprint-1/destructuring/exercise-3/exercise.js @@ -6,3 +6,21 @@ let order = [ { itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 }, { itemName: "Hash Brown", quantity: 4, unitPricePence: 40 }, ]; + +console.log("QTY ITEM TOTAL"); + +let totalPence = 0; + +for (const { itemName, quantity, unitPricePence } of order) { + const itemTotalPence = quantity * unitPricePence; + totalPence += itemTotalPence; + + const formattedItem = itemName === "Hot cakes" ? "Hot Cakes" : itemName; + const formattedTotal = (itemTotalPence / 100).toFixed(2); + + console.log( + `${quantity.toString().padEnd(8)}${formattedItem.padEnd(20)}${formattedTotal}` + ); +} + +console.log(`\nTotal: ${(totalPence / 100).toFixed(2)}`);