All of the cases work with the exception of the NaN case. Why can’t I get it to work?
function bouncer(arr) {
let newArray = […arr];// creating a new Array and setting it equal to arr to prevent mutating arr.
let newNewArray = ; // creating the final array
for(let i=0;i<newArray.length;i++){
switch(newArray[i]){ //switch statement to cover every case.
case false:
break;
case null:
break;
case 0:
break;
case NaN: //Why is this not working?
break;
case undefined:
break;
case "":
break;
default:
newNewArray.push(newArray[i])
break;
}
}
console.log(newNewArray); //testing again
return newNewArray;
}
bouncer([7, “ate”, “”, false, 9]);
bouncer([“a”, “b”, “c”])
bouncer([false, null, 0, NaN, undefined, “”])
console.clear;