Why is my code for Drop It not working?

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:

It looks like you are missing one part of the requirements. You aren’t filtering the entire array

Then return the rest of the array once the condition is satisfied

This means that you should return the entire remaining portion of the array starting at the first index that passes the function.

In addition to what Jeremy said, you should look into the slice() method, as it would be very helpful on this challenge.