From 99f50ba10dc0aedc367bfce71162ed4eff6833e9 Mon Sep 17 00:00:00 2001 From: Khaliun Baatarkhuu Date: Mon, 10 Aug 2026 21:26:32 +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 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 5d0d0eb1974a479eddd44d832a9f4463ab9040d1 Mon Sep 17 00:00:00 2001 From: Khaliun Baatarkhuu Date: Mon, 10 Aug 2026 21:31:22 +0100 Subject: [PATCH 2/3] Add tasks to filter Hogwarts students by house and occupation --- 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..2fda98e6 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", }, ]; + +//Task 1 + +hogwarts.forEach(({ firstName, lastName, house }) => { + if (house === "Gryffindor") { + console.log(`${firstName} ${lastName}`); + } +}); + +//Task 2 + +hogwarts.forEach(({ firstName, lastName, occupation, pet }) => { + if (occupation === "Teacher" && pet) { + console.log(`${firstName} ${lastName}`); + } +}); + + + From 91bf86c4e5ae957a04af7c99aa30a6b145ce7107 Mon Sep 17 00:00:00 2001 From: Khaliun Baatarkhuu Date: Mon, 10 Aug 2026 21:49:41 +0100 Subject: [PATCH 3/3] Calculate and display total cost of order items --- 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..6813abed 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 ITEM TOTAL"); + +let totalCost = 0; + +order.forEach(({ itemName, quantity, unitPricePence }) => { + const itemTotal = quantity * unitPricePence; + totalCost += itemTotal; + + console.log( + `${quantity} ${itemName.padEnd(20)} ${(itemTotal / 100).toFixed(2)}` + ); +}); + +console.log(`\nTotal: ${(totalCost / 100).toFixed(2)}`);