First thing first, this is a truthy value as it is a string with content inside, it is not falsy. "null" is a string, null is the falsy value you need to remove
same for NaN
but an other reason fro which this will not work is that NaN === NaN is always false. And it is reason why you need to use the falsyness of the values to solve this in a simple way.
because splice changes the array, removing items - the loop is following the indexes, but you change what’s at each index (add console.log(arr) inside the loop to see this).
Do not change arrays you are iterating over, it gets complicated.