Tell us what’s happening:
I don’t see why this is not working. I used a for-lus to iterate the array. In the for-lus there’s a if-lus to see if the current arr[i] is equal to a falsy value. If that is the case than it deletes it + it resets the “i”.
The first test works, but the 2 others not. Can someone help me?
When you do the arr.splice(i,1) you are changing the number of elements in your array and thus the position also changes. Better declare an empty array and push it or use high order function without the need for a for...loop like filter function.
There is a bug also in JS that NaN is not actually equal to NaN. Comparing to one value the work around is using isNaN() function. However for multiple values like this problem, it would not work. A good work around is using includes method in an array. Like someArray['a','b','c'].includes('d') which in this case would return false. And that you have to find out yourself.