I don't understand why this doesn't work

I don't understand why this doesn't work
0

#1

I managed to get all except one of the arguments working, with this very similar to the basic code solution I did.

function dropElements(arr, func) {
  // Drop them elements.
  for (var i = 0 ; i < arr.length; i++){
   if (func(arr[0]) === false){
     arr.shift();
   } else {
     break;
   }
   
 }
  return arr;
}

dropElements([1, 2, 3, 4], function(n) {return n > 5;});

After looking at the example solutions on “get a hint” and even copying it, the code doesn’t work with those arguments, it returns "[3,4]"
Why? none of those are higher than 5, so the function should always return false, and the array become empty.


#4

I had problems with that one until I learned how .find() works.

Combine it with .indexOf() and .slice() and you have solution you need in 4 lines of code.