From 1cddaaabb8d5d8265945ba6816125d91fbf7c7ee Mon Sep 17 00:00:00 2001 From: dona-shehu Date: Wed, 29 Jul 2026 23:07:34 +0100 Subject: [PATCH 1/3] 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/3] 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/3] 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