Skip to content

Commit 002a1ef

Browse files
committed
implement teacherhavepet function
1 parent 2e088c5 commit 002a1ef

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,16 @@ let hogwarts = [
7070
occupation: "Teacher",
7171
},
7272
];
73-
function gryffindorHouse(hogwarts){
73+
function gryffindorHouse(arr){
7474

75-
hogwarts.filter(({house})=>house==="Gryffindor")
75+
arr.filter(({house})=>house==="Gryffindor")
7676
.forEach(({firstName,lastName})=>
7777
console.log(`${firstName} ${lastName}`))
7878
}
79+
function teachersHavePet(arr){
80+
arr.filter(({occupation,pet})=>(occupation==="Teacher" && pet))
81+
.forEach(({firstName,lastName})=> console.log(`${firstName} ${lastName}`))
82+
}
83+
gryffindorHouse(hogwarts);
84+
console.log("***************************************")
85+
teachersHavePet(hogwarts);

0 commit comments

Comments
 (0)