From 861486b27c1a33dfed4eb7213c79b5fddceb7174 Mon Sep 17 00:00:00 2001 From: Aida Eslami Date: Tue, 22 Jul 2025 00:50:23 +0100 Subject: [PATCH 1/3] Update the parameter --- Sprint-1/destructuring/exercise-1/exercise.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sprint-1/destructuring/exercise-1/exercise.js b/Sprint-1/destructuring/exercise-1/exercise.js index 1ff2ac5c..40b01454 100644 --- a/Sprint-1/destructuring/exercise-1/exercise.js +++ b/Sprint-1/destructuring/exercise-1/exercise.js @@ -1,12 +1,12 @@ const personOne = { - name: "Popeye", - age: 34, - favouriteFood: "Spinach", + name: "Aida", + age: 37, + favouriteFood: "Pasta", }; // 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 284bdc392df0efd1880254d3de72149689c36593 Mon Sep 17 00:00:00 2001 From: Aida Eslami Date: Tue, 22 Jul 2025 01:29:14 +0100 Subject: [PATCH 2/3] Hogwarts School --- Sprint-1/destructuring/exercise-2/exercise.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Sprint-1/destructuring/exercise-2/exercise.js b/Sprint-1/destructuring/exercise-2/exercise.js index e11b75eb..ff166e4d 100644 --- a/Sprint-1/destructuring/exercise-2/exercise.js +++ b/Sprint-1/destructuring/exercise-2/exercise.js @@ -70,3 +70,34 @@ let hogwarts = [ occupation: "Teacher", }, ]; + + +function studentInfo(hogwarts) + +{ +hogwarts.forEach(person => { + const{firstName,lastName,house}=person; + if(house=="Gryffindor") + console.log(firstName,lastName) + +}); +} + +function petOwner(hogwarts){ +hogwarts.forEach(person=> +{ + const{firstName,lastName,occupation,pet}=person; + if (occupation=="Teacher" && pet!=null) + console.log(firstName,lastName) + +} +) +} + + +console.log("Display the names of the people who belong to the Gryffindor house: ") +studentInfo(hogwarts) + + +console.log("\nDisplay the names of teachers who have pets:") +petOwner(hogwarts) \ No newline at end of file From 3e204dc7810b410ef78c810539c47d11645eaf43 Mon Sep 17 00:00:00 2001 From: Aida Eslami Date: Tue, 22 Jul 2025 02:17:05 +0100 Subject: [PATCH 3/3] Receipt --- Sprint-1/destructuring/exercise-3/exercise.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Sprint-1/destructuring/exercise-3/exercise.js b/Sprint-1/destructuring/exercise-3/exercise.js index b3a36f4e..ba67e66f 100644 --- a/Sprint-1/destructuring/exercise-3/exercise.js +++ b/Sprint-1/destructuring/exercise-3/exercise.js @@ -6,3 +6,30 @@ let order = [ { itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 }, { itemName: "Hash Brown", quantity: 4, unitPricePence: 40 }, ]; + + + +function printReceipt(order) { + let total = 0; + console.log("QTY ITEM TOTAL"); + order.forEach(record => { + const { itemName, quantity, unitPricePence } = record; + const lineTotal = quantity * unitPricePence; + total += lineTotal; + + console.log( + String(quantity).padEnd(5) + + itemName.padEnd(20) + + convertPenceToPound(lineTotal).padStart(6) + ); + }); + + console.log("\nTotal: " + convertPenceToPound(total)); +} + +function convertPenceToPound(pence) { + const pounds = Number(pence) / 100; + return pounds.toFixed(2); +} + +printReceipt(order);