Tell us what’s happening:
I am having an issue with two of the test cases which actually shouldn’t have to comply:
dropElements([0, 1, 0, 1], function(n) {return n === 1;}) should return [1, 0, 1]
If n===1, then 0 should not be returned, so here, my code crashes and cannot keep on advancing…
dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;}) should return [3, 9, 2]
If n>2, then 2 should not be returned, thus my code crashes since the test case says the opposite…
I attach here my code:
**Your code so far**
function dropElements(arr, func) {
const result = arr.filter(func);
console.log(result)
return result;
}
dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;});
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36
I realise that makes it bit more difficult in that case! As it is, there are loads of learners who make the exact same mistake when it’s their first language, so you’re not alone in being a bit confused about the test cases