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.