Skip to content

Commit 798da30

Browse files
committed
excercise-2
1 parent 59f3869 commit 798da30

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,17 @@ let hogwarts = [
7070
occupation: "Teacher",
7171
},
7272
];
73+
74+
// Task 1: Display names of people in Gryffindor house
75+
hogwarts.forEach(({ firstName, lastName, house }) => {
76+
if (house === "Gryffindor") {
77+
console.log(`${firstName} ${lastName}`);
78+
}
79+
});
80+
81+
// Task 2: Display names of teachers with pets
82+
hogwarts.forEach(({ firstName, lastName, occupation, pet }) => {
83+
if (occupation === "Teacher" && pet) {
84+
console.log(`${firstName} ${lastName}`);
85+
}
86+
});

0 commit comments

Comments
 (0)