From 1cddaaabb8d5d8265945ba6816125d91fbf7c7ee Mon Sep 17 00:00:00 2001 From: dona-shehu Date: Wed, 29 Jul 2026 23:07:34 +0100 Subject: [PATCH 1/8] Introduce yourself destructuring object --- Sprint-1/destructuring/exercise-1/exercise.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Sprint-1/destructuring/exercise-1/exercise.js b/Sprint-1/destructuring/exercise-1/exercise.js index 1ff2ac5c..f4e48506 100644 --- a/Sprint-1/destructuring/exercise-1/exercise.js +++ b/Sprint-1/destructuring/exercise-1/exercise.js @@ -1,14 +1,15 @@ const personOne = { - name: "Popeye", + firstName: "Popeye", age: 34, favouriteFood: "Spinach", }; - + +let {firstName, age, favouriteFood} = personOne // Update the parameter to this function to make it work. // Don't change anything else. -function introduceYourself(___________________________) { +function introduceYourself() { console.log( - `Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.` + `Hello, my name is ${firstName}. I am ${age} years old and my favourite food is ${favouriteFood}.` ); } From c92876ee0a3b7f5b121e1ba7244b204efedde7c9 Mon Sep 17 00:00:00 2001 From: dona-shehu Date: Wed, 29 Jul 2026 23:09:20 +0100 Subject: [PATCH 2/8] gryffindor and teacherWithPet, destructuring array of objects --- Sprint-1/destructuring/exercise-2/exercise.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Sprint-1/destructuring/exercise-2/exercise.js b/Sprint-1/destructuring/exercise-2/exercise.js index e11b75eb..2852173f 100644 --- a/Sprint-1/destructuring/exercise-2/exercise.js +++ b/Sprint-1/destructuring/exercise-2/exercise.js @@ -70,3 +70,27 @@ let hogwarts = [ occupation: "Teacher", }, ]; +function gryffindorforStudent(){ + let allStudents = ""; + for(let student of hogwarts){ + let {firstName,lastName,house,pet,occupation} = student; + if (house === "Gryffindor"){ + allStudents += `${firstName} ${lastName}\n` + } + } + return allStudents; +} + +function teacherWithPet(){ + let allTeachers = ""; + for(const person of hogwarts){ + let {firstName, lastName,pet, occupation} = person; + if(occupation === "Teacher" && pet !== null){ + allTeachers += `${firstName} ${lastName}\n`; + } + } + return allTeachers; +} + +console.log(teacherWithPet(hogwarts)) +console.log(gryffindorforStudent(hogwarts)) \ No newline at end of file From 7155b0bd2a4601a8d504a7cf43568f0b2bfe3b97 Mon Sep 17 00:00:00 2001 From: dona-shehu Date: Wed, 29 Jul 2026 23:26:30 +0100 Subject: [PATCH 3/8] Reversing changes on main. --- Sprint-1/destructuring/exercise-1/exercise.js | 11 ++++---- Sprint-1/destructuring/exercise-2/exercise.js | 26 +------------------ 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/Sprint-1/destructuring/exercise-1/exercise.js b/Sprint-1/destructuring/exercise-1/exercise.js index f4e48506..f3eecbd6 100644 --- a/Sprint-1/destructuring/exercise-1/exercise.js +++ b/Sprint-1/destructuring/exercise-1/exercise.js @@ -1,16 +1,15 @@ const personOne = { - firstName: "Popeye", + name: "Popeye", age: 34, favouriteFood: "Spinach", }; - -let {firstName, age, favouriteFood} = personOne + // Update the parameter to this function to make it work. // Don't change anything else. -function introduceYourself() { +function introduceYourself(___________________________) { console.log( - `Hello, my name is ${firstName}. I am ${age} years old and my favourite food is ${favouriteFood}.` + `Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.` ); } -introduceYourself(personOne); +introduceYourself(personOne); \ No newline at end of file diff --git a/Sprint-1/destructuring/exercise-2/exercise.js b/Sprint-1/destructuring/exercise-2/exercise.js index 2852173f..c16caccf 100644 --- a/Sprint-1/destructuring/exercise-2/exercise.js +++ b/Sprint-1/destructuring/exercise-2/exercise.js @@ -69,28 +69,4 @@ let hogwarts = [ pet: "Phoenix", occupation: "Teacher", }, -]; -function gryffindorforStudent(){ - let allStudents = ""; - for(let student of hogwarts){ - let {firstName,lastName,house,pet,occupation} = student; - if (house === "Gryffindor"){ - allStudents += `${firstName} ${lastName}\n` - } - } - return allStudents; -} - -function teacherWithPet(){ - let allTeachers = ""; - for(const person of hogwarts){ - let {firstName, lastName,pet, occupation} = person; - if(occupation === "Teacher" && pet !== null){ - allTeachers += `${firstName} ${lastName}\n`; - } - } - return allTeachers; -} - -console.log(teacherWithPet(hogwarts)) -console.log(gryffindorforStudent(hogwarts)) \ No newline at end of file +]; \ No newline at end of file From 50821750ab194e47424e1a82c8003ff664c7c6de Mon Sep 17 00:00:00 2001 From: dona-shehu Date: Thu, 30 Jul 2026 00:23:37 +0100 Subject: [PATCH 4/8] Object destructuring --- Sprint-1/destructuring/exercise-1/exercise.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-1/destructuring/exercise-1/exercise.js b/Sprint-1/destructuring/exercise-1/exercise.js index f3eecbd6..b5cd39bd 100644 --- a/Sprint-1/destructuring/exercise-1/exercise.js +++ b/Sprint-1/destructuring/exercise-1/exercise.js @@ -6,7 +6,8 @@ const personOne = { // Update the parameter to this function to make it work. // Don't change anything else. -function introduceYourself(___________________________) { +function introduceYourself() { + let {name,age,favouriteFood} = personOne; console.log( `Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.` ); From e83b6ca819977b8fe0693759d5eaef7464d31a71 Mon Sep 17 00:00:00 2001 From: dona-shehu Date: Thu, 30 Jul 2026 00:24:15 +0100 Subject: [PATCH 5/8] Destructuring array of objects --- Sprint-1/destructuring/exercise-2/exercise.js | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Sprint-1/destructuring/exercise-2/exercise.js b/Sprint-1/destructuring/exercise-2/exercise.js index c16caccf..b461131d 100644 --- a/Sprint-1/destructuring/exercise-2/exercise.js +++ b/Sprint-1/destructuring/exercise-2/exercise.js @@ -69,4 +69,35 @@ let hogwarts = [ pet: "Phoenix", occupation: "Teacher", }, -]; \ No newline at end of file +]; + +function gryffindorResident(){ + let residents = ""; + for(let resident of hogwarts){ + let {firstName,lastName,house,pet,occupation} = resident; + if(house === "Gryffindor"){ + residents += `${firstName} ${lastName}\n`; + } + } + console.log(residents) + return residents; +} + +function teachersWithPet(){ + let teachers = ""; + for(let teacher of hogwarts){ + let{firstName,lastName,house,pet,occupation} = teacher; + if(occupation === "Teacher" && pet !== null){ + teachers += `${firstName} ${lastName}\n`; + } + } + console.log(teachers); + return teachers; +} + +gryffindorResident(hogwarts); +teachersWithPet(hogwarts) + + + + From ec64189b84568d48de3d12976375b4e4d4e94983 Mon Sep 17 00:00:00 2001 From: dona-shehu Date: Fri, 31 Jul 2026 00:08:16 +0100 Subject: [PATCH 6/8] receipt() using destructuring, padEnd , toFixed --- Sprint-1/destructuring/exercise-3/exercise.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Sprint-1/destructuring/exercise-3/exercise.js b/Sprint-1/destructuring/exercise-3/exercise.js index b3a36f4e..c0b85987 100644 --- a/Sprint-1/destructuring/exercise-3/exercise.js +++ b/Sprint-1/destructuring/exercise-3/exercise.js @@ -6,3 +6,23 @@ let order = [ { itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 }, { itemName: "Hash Brown", quantity: 4, unitPricePence: 40 }, ]; + +function receipt(order) { + let totalPrice = 0; + + console.log("QTY".padEnd(10) + "Item".padEnd(20) + "TOTAL"); + for (const item of order) { + let { itemName, quantity, unitPricePence } = item; + let pricePerQuantity = quantity * unitPricePence; + console.log( + String(quantity).padEnd(10) + + itemName.padEnd(20) + + (pricePerQuantity / 100).toFixed(2) + ); + totalPrice += pricePerQuantity; + } + totalPrice = (totalPrice / 100).toFixed(2); + console.log(`TOTAL: ${totalPrice}`); +} + +receipt(order); From 73c06ab256677d58a7cadd310b95bf4522cd96ce Mon Sep 17 00:00:00 2001 From: dona-shehu Date: Mon, 3 Aug 2026 15:58:47 +0100 Subject: [PATCH 7/8] reversed the changes by mistake. pushing them back --- Sprint-1/destructuring/exercise-1/exercise.js | 8 ++-- Sprint-1/destructuring/exercise-2/exercise.js | 39 ++++++++----------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/Sprint-1/destructuring/exercise-1/exercise.js b/Sprint-1/destructuring/exercise-1/exercise.js index b5cd39bd..858feaf2 100644 --- a/Sprint-1/destructuring/exercise-1/exercise.js +++ b/Sprint-1/destructuring/exercise-1/exercise.js @@ -1,16 +1,16 @@ const personOne = { - name: "Popeye", + firstName: "Popeye", age: 34, favouriteFood: "Spinach", }; +let { firstName, age, favouriteFood } = personOne; // Update the parameter to this function to make it work. // Don't change anything else. function introduceYourself() { - let {name,age,favouriteFood} = personOne; console.log( - `Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.` + `Hello, my name is ${firstName}. I am ${age} years old and my favourite food is ${favouriteFood}.` ); } -introduceYourself(personOne); \ No newline at end of file +introduceYourself(personOne); diff --git a/Sprint-1/destructuring/exercise-2/exercise.js b/Sprint-1/destructuring/exercise-2/exercise.js index b461131d..6cec9155 100644 --- a/Sprint-1/destructuring/exercise-2/exercise.js +++ b/Sprint-1/destructuring/exercise-2/exercise.js @@ -70,34 +70,27 @@ let hogwarts = [ occupation: "Teacher", }, ]; - -function gryffindorResident(){ - let residents = ""; - for(let resident of hogwarts){ - let {firstName,lastName,house,pet,occupation} = resident; - if(house === "Gryffindor"){ - residents += `${firstName} ${lastName}\n`; +function gryffindorforStudent() { + let allStudents = ""; + for (let student of hogwarts) { + let { firstName, lastName, house, pet, occupation } = student; + if (house === "Gryffindor") { + allStudents += `${firstName} ${lastName}\n`; } } - console.log(residents) - return residents; + return allStudents; } -function teachersWithPet(){ - let teachers = ""; - for(let teacher of hogwarts){ - let{firstName,lastName,house,pet,occupation} = teacher; - if(occupation === "Teacher" && pet !== null){ - teachers += `${firstName} ${lastName}\n`; +function teacherWithPet() { + let allTeachers = ""; + for (const person of hogwarts) { + let { firstName, lastName, pet, occupation } = person; + if (occupation === "Teacher" && pet !== null) { + allTeachers += `${firstName} ${lastName}\n`; } } - console.log(teachers); - return teachers; + return allTeachers; } -gryffindorResident(hogwarts); -teachersWithPet(hogwarts) - - - - +console.log(teacherWithPet(hogwarts)); +console.log(gryffindorforStudent(hogwarts)); From 692b61ea8892203f6a8e67f3a47877550873097f Mon Sep 17 00:00:00 2001 From: dona-shehu Date: Mon, 3 Aug 2026 23:24:00 +0100 Subject: [PATCH 8/8] Pushing the changes in github after accidentally deleted them while trying to bring main in first state. --- Sprint-1/destructuring/exercise-1/exercise.js | 2 +- Sprint-1/destructuring/exercise-3/exercise.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Sprint-1/destructuring/exercise-1/exercise.js b/Sprint-1/destructuring/exercise-1/exercise.js index 858feaf2..1ef36775 100644 --- a/Sprint-1/destructuring/exercise-1/exercise.js +++ b/Sprint-1/destructuring/exercise-1/exercise.js @@ -13,4 +13,4 @@ function introduceYourself() { ); } -introduceYourself(personOne); +console.log(introduceYourself(personOne)); diff --git a/Sprint-1/destructuring/exercise-3/exercise.js b/Sprint-1/destructuring/exercise-3/exercise.js index c0b85987..7a6fbd43 100644 --- a/Sprint-1/destructuring/exercise-3/exercise.js +++ b/Sprint-1/destructuring/exercise-3/exercise.js @@ -22,7 +22,6 @@ function receipt(order) { totalPrice += pricePerQuantity; } totalPrice = (totalPrice / 100).toFixed(2); - console.log(`TOTAL: ${totalPrice}`); } -receipt(order); +console.log(receipt(order));