Don't understand what I'm supposed to do with drop it

So this isn’t about my code, I just don’t understand the test cases.
I thought you were supposed to return an array with all the elements that are true when passed into the function but then:

“dropElements([0, 1, 0, 1], function(n) {return n === 1;})should return[1, 0, 1]` .”

0 does not === 1? and also “dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;}) should return [3, 9, 2].” why should 2 be returned?

Thanks!

You should read again the problem requirements:

Given the array arr, iterate through and remove each element starting from the first element (the 0 index) until the function func returns true when the iterated element is passed through it.

Then return the rest of the array once the condition is satisfied, otherwise, arr should be returned as an empty array.

So basically you have to find the first element which returns true when you apply that function to it, and only return the rest of the elements. If none is found, you should return an empty array.

Hope this explains it better!

1 Like

Thanks! I got mixed up and thought it wanted to iterate through and check ALL the elements passed. That makes more sense now!

1 Like

I’m glad you understood now! :smiley: Good luck solving it!