Skip to content

Commit b07cf4e

Browse files
committed
Completed Hogwarts exercise with destructuring
1 parent 004337d commit b07cf4e

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Sprint-1/destructuring/exercise-2/exercise.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,23 @@ let hogwarts = [
7070
occupation: "Teacher",
7171
},
7272
];
73+
74+
75+
// Task 1: Gryffindor members
76+
hogwarts.forEach((person) => {
77+
const { firstName, lastName, house } = person;
78+
79+
if (house === "Gryffindor") {
80+
console.log(`${firstName} ${lastName}`);
81+
}
82+
});
83+
84+
85+
// Task 2: Teachers with pets
86+
hogwarts.forEach((person) => {
87+
const { firstName, lastName, occupation, pet } = person;
88+
89+
if (occupation === "Teacher" && pet) {
90+
console.log(`${firstName} ${lastName}`);
91+
}
92+
});

0 commit comments

Comments
 (0)