Help on splice not getting how its working and whats wrong with my code?

function bouncer(arr) {

// Don't show a false ID to this bouncer.

for(let i=0; i < arr.length; i++) {
 if(arr[i]===false && arr[i]===null && arr[i]===0 && arr[i]==="" && arr[i]===undefined && arr[i]===NaN){

  return arr;

bouncer([7, "ate", "", false, 9]);

I’m not getting what’s wrong is happening here, someone please help?

You have an extra } at the end, and NaN does not equal anything, even itself, so you cannot test it that way (you can test it in this case like arr[i] !== arr[i], eg the element is not the same as itself). The big long condition is not the idea way to do this though, the exercise is trying to teach you about truthy and falsely values

1 Like

You’re only executing the code if ALL those conditions are true. I imagine that’s why the code is failing.

A quick tip: since you’re checking for falsy values, you might use !arr[i]) instead of that lengthy condition list. This will evaluate to true (and execute the if statement) anytime the arr[i] is no a truthy value.

Falsy values are false, null, undefined, NaN, 0 (number), an empty string. Everything else is truthy.

1 Like

Ah, I was concentrating on trying to clean the OP’s code and completely missed that, that’s a pretty major problem.