From e7dc2180b31e507c10b64d39ffc20655ff33e9da Mon Sep 17 00:00:00 2001 From: ChinweP Date: Sat, 1 Aug 2026 00:34:05 +0100 Subject: [PATCH 1/3] Add object destructuring to introduceYourself function --- 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 1ff2ac5c..d86bc7bf 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 48d81717763e1939d8c40b8158fd123e0fe61807 Mon Sep 17 00:00:00 2001 From: ChinweP Date: Sat, 1 Aug 2026 00:59:11 +0100 Subject: [PATCH 2/3] Filter Hogwarts data using object destructuring --- Sprint-1/destructuring/exercise-2/exercise.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Sprint-1/destructuring/exercise-2/exercise.js b/Sprint-1/destructuring/exercise-2/exercise.js index e11b75eb..e0759523 100644 --- a/Sprint-1/destructuring/exercise-2/exercise.js +++ b/Sprint-1/destructuring/exercise-2/exercise.js @@ -70,3 +70,22 @@ let hogwarts = [ occupation: "Teacher", }, ]; + +hogwarts.forEach((person) => { + const { firstName, lastName, house } = person; + + if (house === "Gryffindor") { + console.log(`${firstName} ${lastName}`); + } +}); + + +hogwarts.forEach((person) => { + const { firstName, lastName, occupation, pet } = person; + + if (occupation === "Teacher" && pet) { + console.log(`${firstName} ${lastName}`); + } +}); + + From 253c6fcba56b080f74fb5afd3df8d1727b8784fa Mon Sep 17 00:00:00 2001 From: ChinweP Date: Sat, 1 Aug 2026 01:12:08 +0100 Subject: [PATCH 3/3] Generate receipt by destructuring order items and calculating totals --- 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 b3a36f4e..f706f902 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 total = 0; + +order.forEach((product) => { + const { itemName, quantity, unitPricePence } = product; + + const price = unitPricePence / 100; + const lineTotal = quantity * price; + total += lineTotal; + + console.log( + `${quantity} ${itemName.padEnd(18)} ${lineTotal.toFixed(2)}` + ); +}); + +console.log(`\nTotal: ${total.toFixed(2)}`);