From 4cb12f4fe6a57cc31173b5555aad78a53e1c5275 Mon Sep 17 00:00:00 2001 From: TTiamiyu Date: Tue, 4 Aug 2026 01:12:18 +0100 Subject: [PATCH 1/4] 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 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 ac341ac98d4696fad04af69c5020caf0ed9c5422 Mon Sep 17 00:00:00 2001 From: TTiamiyu Date: Tue, 4 Aug 2026 01:15:45 +0100 Subject: [PATCH 2/4] Add tasks to display Gryffindor students 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 e11b75eb..2a8a223a 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", }, ]; + +console.log("--- Task 1: Gryffindor ---"); +hogwarts.forEach(({ firstName, lastName, house }) => { + if (house === "Gryffindor") { + console.log(`${firstName} ${lastName}`); + } +}); + +console.log("\n--- Task 2: Teachers with Pets ---"); +hogwarts.forEach(({ firstName, lastName, pet, occupation }) => { + if (occupation === "Teacher" && pet !== null) { + console.log(`${firstName} ${lastName}`); + } +}); From 7ecb7d1a1bad2ac7cd8e130aa6a527963308d139 Mon Sep 17 00:00:00 2001 From: TTiamiyu Date: Tue, 4 Aug 2026 01:18:41 +0100 Subject: [PATCH 3/4] Refactor order summary display to improve readability and formatting --- Sprint-1/destructuring/exercise-3/exercise.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Sprint-1/destructuring/exercise-3/exercise.js b/Sprint-1/destructuring/exercise-3/exercise.js index b3a36f4e..4b5d1488 100644 --- a/Sprint-1/destructuring/exercise-3/exercise.js +++ b/Sprint-1/destructuring/exercise-3/exercise.js @@ -6,3 +6,18 @@ let order = [ { itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 }, { itemName: "Hash Brown", quantity: 4, unitPricePence: 40 }, ]; + +console.log("QTY\tITEM\t\t\tTOTAL"); + +let total = 0; + +for (let { itemName, quantity, unitPricePence } of order) { + let itemTotal = (quantity * unitPricePence) / 100; + total += itemTotal; + + console.log( + `${quantity}\t${itemName.padEnd(20, " ")}${itemTotal.toFixed(2)}` + ); +} + +console.log(`\nTotal: ${total.toFixed(2)}`); From c47e779c8649b4cc0b149dec523236d27986f20a Mon Sep 17 00:00:00 2001 From: TTiamiyu Date: Sat, 8 Aug 2026 11:56:10 +0100 Subject: [PATCH 4/4] Simplify condition to check for teachers with pets --- 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 2a8a223a..7e7bf167 100644 --- a/Sprint-1/destructuring/exercise-2/exercise.js +++ b/Sprint-1/destructuring/exercise-2/exercise.js @@ -80,7 +80,7 @@ hogwarts.forEach(({ firstName, lastName, house }) => { console.log("\n--- Task 2: Teachers with Pets ---"); hogwarts.forEach(({ firstName, lastName, pet, occupation }) => { - if (occupation === "Teacher" && pet !== null) { + if (occupation === "Teacher" && pet) { console.log(`${firstName} ${lastName}`); } });