Drop it - all but one case passes

function dropElements(arr, func) {
  // Drop them elements.
  while (!func(arr.slice(0,1))){
   arr.shift();
  }
   return arr
  }


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

This never evaluates to true and I can’t figure out why. All other cases pass. I have researched strict equality but can;t see why this doesn’t work.

.slice() returns an array. The function makes strict equal check and array === 1 will always return false, so your while loop will run forever (if you slice an empty array, you’ll get an empty array in return).

Thank you for helping

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.