Tell us what’s happening:
This code passes all the tests except :
dropElements([0, 1, 0, 1], function(n) {return n === 1;}).
It keeps slicing the array one index off from the rest. I don’t understand why.
**Your code so far**
function dropElements(arr, func) {
let anw = "";
//console.log(func(arr[1]))
for(let i = 0; i < arr.length; i++) {
//console.log(i);
//console.log(arr[i]);
if(func(arr[i])) {
return arr.slice(arr[i-1]);
};
};
return [];
}
console.log(dropElements([1, 2, 3], function(n) {return n < 3; }));
console.log(dropElements([1, 2, 3, 4], function(n) {return n >= 3;}))
console.log(dropElements([0, 1, 0, 1], function(n) {return n === 1;}));
**Your browser information:**
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14695.85.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36
Challenge: Drop it
Link to the challenge: