Falsy Bouncer: NaN is not a falsy?

When I run my code, every case is right but Nan is not right. What happen to this case?
Please help! I’m stuck here.


Your code so far

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  let falsyArr = [false, null, 0, "", undefined, NaN];
  let temp = [];

  for(let i = 0; i < arr.length; i++){

    if(falsyArr.indexOf(arr[i]) < 0){

  return temp;

bouncer([false, null, 0, NaN, undefined, ""]);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15.

Link to the challenge:

If you write
let a = NaN == NaN;, a will be false
Your issue is there, as you are checking based on a list of values

Instead, you can use directly the value, in the sense that if you write !NaN it is true, if you write !null it is true, etc

1 Like