This answer fails the second and last tests, but I’m not sure why?
Returns [1, 2] instead of [1, 0, 1] and
[1, 2] instead of [3, 9, 2].
Also, why would the answer to the second test be [1, 0, 1] instead of [1, 1]? Isn’t that function supposed to be true only when n === 1? Why is that 0 there…
function dropElements(arr, func) {
var result = []
for (let i = 0; i < arr.length; i++) {
if (func(arr[i])) {
result.push(arr[i])
} else {
continue;
}
}
console.log(result)
return result
}
Challenge: Drop it
Link to the challenge: