Intermediate Algorithm Scripting - Drop it(Given the array arr, iterate through and remove each element starting from the first element (the 0 index) until the

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

don’t change the array you are iterating over. you may want to use a while loop here

also break will not break from forEach