-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgooseFilter.js
26 lines (21 loc) · 952 Bytes
/
gooseFilter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// P -> array
// R -> array with elements that are not in de params array
// E -> ["African", "Roman Tufted", "Toulouse", "Pilgrim", "Steinbacher"]
// ["Mallard", "Hook Bill", "African", "Crested", "Pilgrim", "Toulouse", "Blue Swedish"]
// returning arr -> ["Mallard", "Hook Bill", "Crested", "Blue Swedish"]
// P -> loop or method
// check if birds includes geese
// push to new arr
function gooseFilter(birds) {
var geese = ["African", "Roman Tufted", "Toulouse", "Pilgrim", "Steinbacher"];
let newArr = [];
// return an array containing all of the strings in the input array except those that match strings in geese
for (let bird of birds) {
if (!geese.includes(bird))
newArr.push(bird)
}
return newArr
};
console.log(gooseFilter(["Mallard", "Hook Bill", "African", "Crested", "Pilgrim", "Toulouse", "Blue Swedish"]))
// Method filter
// birds.filter(bird => !geese.includes(bird)