Tell us what’s happening:
I need some guidance for this test, not sure how to write the logic to get the correct positions when looping through the array
Your code so far
function dropElements (arr, func) {
for (let i = 0; i < arr.length; i++) {
let index = arr.indexOf(i);
if (func(i)) {
return arr.slice(index);
}
}
}
console.log(dropElements([1, 2, 3, 4], function(n) {return n >= 3;})) //expected [3,4]
console.log(dropElements([0, 1, 0, 1], function(n) {return n === 1;})) //expected [1, 0, 1]
console.log(dropElements([1, 2, 3], function(n) {return n > 0;})) //expected [1, 2, 3]
console.log(dropElements([1, 2, 3, 4], function(n) {return n > 5;})) //expected []
console.log(dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;})) //expected [7, 4]
console.log(dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;})) //expected [3, 9, 2]
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Challenge Information:
Implement an Element Skipper - Implement an Element Skipper