Drop it - all but one case passes


#1
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.


#2

.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).


#3

Thank you for helping


#4

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