Tell us what’s happening:
need help of someone checking my code:
function dropElements(arr, func) {
arr.forEach((item)=>{
if (func(item)) {
break;
}
else{
arr.shift();
}
})
return arr;
}
i have iterated through the arr using forEach loop
Your code so far
function dropElements(arr, func) {
arr.forEach((item)=>{
if (func(item)) {
break;
}
else{
arr.shift();
}
})
return arr;
}
dropElements([1, 2, 3], function(n) {return n < 3; });
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Challenge Information:
Intermediate Algorithm Scripting - Drop it