Skip to content

Commit e58b013

Browse files
committed
feat: add function to retrieve Gryffindor students from Hogwarts array
1 parent a71afe1 commit e58b013

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,14 @@ let hogwarts = [
7070
occupation: "Teacher",
7171
},
7272
];
73+
74+
function getGryffindors(arr) {
75+
let Gryffindors = []
76+
for (let person of arr) {
77+
if (person["house"] === "Gryffindor") {
78+
Gryffindors.push(`${person["firstName"]} ${person.lastName}`);
79+
}
80+
}
81+
return Gryffindors;
82+
}
83+
console.log(getGryffindors(hogwarts));

0 commit comments

Comments
 (0)