Tell us what’s happening:
Hello.
Tests 2, 3, 6 and 7 are failing.
I have tried different variations of this code and this makes the most sense to me so far. For test 2, the function is returning [2, 3, 4] which I don’t understand because 2 shouldn’t be returning true from the input func.
Your code so far
function dropElements(arr, func) {
for (const item of arr) {
if (func(item) == false) {
arr.splice(arr.indexOf(item), 1);
} else {
return arr;
}
}
return [];
}
console.log(dropElements([1, 2, 3, 4], function(n) {return n >= 3;}));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:155.0) Gecko/20100101 Firefox/155.0
Challenge Information:
Implement an Element Skipper - Implement an Element Skipper