Tell us what’s happening:
Describe your issue in detail here.
In this my simple approach is to iterate over the whole array, break the loop as soon as function returns true. And till when the function returns false remove that element from the array. But despite of break the loop is iterating through the whole array length.
double check how your code behaves. As soon as the function returns true, your loop breaks and nothing executes. In the example case with [1,2,3], the loop breaks on the first element and does nothing to the array
Your code is doing the dangerous thing of modifying both the index i and the length of the array itself. This can often lead to unintentionally skipping over elements.
e.g. say you find func(arr[i]) to be false at index 0, and splice, the element you want to look at next was index 1 but now is at 0. However your i has moved on to 1.