The task of this is to remove any nested array that has the element inside?..if so,i would suggest just pushing the arr[i] in newArr if the arr[i].indexof(elem) !== -1 and rreturn newArr
You’re absolutely correct. And that is the solution that probably makes more sense. But I am trying to wrap my head around why this particular method doesn’t work. I keep trying to run through it and I would love someone to explain why it’s not working.
The fact that it works for all test arrays except one is especially annoying!
Oh ok,i misunderstood your point here…I’m not able to test your code right now but it’s not advisable to splice the given array because it alters it and becomes a mess…if i test it and find the exact problem,i will reply back
Splice removes elements, which then means you shift all of the elements past the deleted one. You end up skipping over elements. Because you deleted an element and then increased i.