Intermediate Algorithm Scripting - Drop it

Tell us what’s happening:
I came up with a solution and it passes the challenge, at least the test cases that are required to pass. But the initial arguments proposed in the challenge
dropElements([1, 2, 3], function(n) {return n < 3; } does not pass.

Your code so far

function dropElements(arr, func) {
  let newArr = [];
  for (let i = 0; i < arr.length; i++) {
    if (func(arr[i])) {
      newArr = arr.slice(i);
      break;
    }
  }
  return newArr;
}

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

I understand that the problem is that the for loop breaks as soon as the function condition is satisfied (n < 3).
arr[0] is 1 and the condition is immediately satisfied.
I noticed that all of the test case conditions use ‘greater than’, ‘greater than or equal to’ or ‘strictly equal’. None of the test cases use ‘less than or equal to’.
I know it passes the challenge, but the fact that the default arguments did not pass is really bugging me.
I am very new to coding and I was wondering if there is a way to identify the index of the slice position, regardless of whether the comparison operator is ‘less than’ or ‘greater than’.

I’m not looking to be spoon fed. Any hints or suggestions would be appreciated.

I am not following what you mean by does not pass. The instruction states:

Then return the rest of the array once the condition is satisfied, otherwise, arr should be returned as an empty array.

In the case you have proposed, the first element of the array satisfies the callback function’s condition of n < 3 because 1 is less than 3, so the first element through the rest of the array would get returned. [1, 2, 3] should be returned and it is.

:astonished: Thank you so much for that clarification. I would’ve been struggling with this for days if it wasn’t for you.
I was so fixated on ‘n < 3’ that I thought the return value should be [1, 2].
Like I said, I am very new to this and today I learned that understanding the problem is half the battle, maybe more.
Thanks again!