Skip to content

Commit a28710a

Browse files
committed
Filter and log only Gryffindor students from hogwarts array
1 parent 2ea2b47 commit a28710a

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ let hogwarts = [
7272
];
7373
function getGryffindorStudents(hogwarts) {
7474
for (const { firstName, lastName, house } of hogwarts) {
75-
if (house === "Gryffindor") {
75+
if (house === "Gryffindor") {
7676
console.log(`${firstName} ${lastName}`);
7777
}
7878
}
@@ -88,4 +88,12 @@ function getTeachersWithPets(hogwarts) {
8888
}
8989
}
9090

91-
getTeachersWithPets(hogwarts);
91+
getTeachersWithPets(hogwarts);
92+
function getGryffindorStudents(hogwarts) {
93+
for (const { firstName, lastName, house, occupation } of hogwarts) {
94+
if (house === "Gryffindor" && occupation === "Student") {
95+
console.log(`${firstName} ${lastName}`);
96+
}
97+
}
98+
}
99+
getGryffindorStudents(hogwarts);

0 commit comments

Comments
 (0)