Removing items from the aray which donot satisfy the function

i didnt understand the for loop here . what happens when the func(arr[0]) becomes true ??

Your code so far


function dropElements(arr, func) {
let times = arr.length;

for( let i = 0; i <times; i++)
{
  if(func(arr[0]))
  {
    break;
  }
 else 
  {
    arr.shift();
  }
}
return arr;
}

dropElements([1, 2, 3], function(n) {return n < 3; });

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; SM-A205YN) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36.

Challenge: Drop it

Link to the challenge:

The loop stops, that’s what break does

the break keyword stops a loop, so at that point the loop is exited and the code after the loop executes