I wrote a script to remove any null, undefined, 0, false or empty string value using .splice(), but the code has only removed NaN and 0s.
Here is what I tried:
function remove(arr){ // input [NaN, 0, 15, false, -22, '',undefined, 47, null]
var bin = [];
for (var i =0; i<arr.length; i++){
if (arr[i] == (NaN || 0 || false || "" || undefined || null)){
arr.splice(arr[i],1);
}
}
console.log(arr); // Expected output [15, -22, 47]
}