I have a set of keys (for example 2,3,4,101,102,454).
I’d like to remove elements with these keys from an array.
Is there a way to remove them all at once?
I tried iterating through for loop, and using splice
to remove elements one by one, but that never removed
all elements – my guess is because it modifies the
array I’m looping through.
go backwards.
If you loop thru from 0 -> n, you modify the indexes of the elements coming after an item you just removed.
If you go backwards, from n -> 0, you don’t have that problem.