The second test case goes as follows:
dropElements([0, 1, 0, 1], function(n) {return n === 1;})
should return [1, 0, 1]
.
Why is it supposed to return [1, 0, 1]
?
0===1
yields false
1===1
yields true
0===1
yields false
1===1
yields true
So the function should return [1,1]
But the test case needs it to be [1, 0, 1]
Same for dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;})
should return [3, 9, 2]
.
Why is that? Am I misunderstanding the task?
**Your code so far**
function dropElements(arr, func) {
return arr.filter(item => func(item))
}
dropElements([1, 2, 3], function(n) {return n < 3; });
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36
Challenge: Intermediate Algorithm Scripting - Drop it
Link to the challenge: