Everything be true, but why also NaN?

Everything be true, but why also NaN?
0.0 0

#1

Hi! At the end I passed the challenge with a different, shorter code, but I can’t understand the reason why with the following code the last test case with NaN value (truthCheck([{"single": "double"}, {"single": NaN}], "single")) returns true… What am I missing?

###spoiler alert!

function truthCheck(collection, pre) {
  // Is everyone being true?
 
  for(var i in collection) {
    
    switch(collection[i][pre]){
      case null:
      case undefined:
      case 0:
      case NaN:
      case '':
      case "":
        return false;
    }
  
  }
 return true;

}

#2

Maybe it’s because NaN is not equal to itself, so the program isn’t finding that case.


#3

NaN is the only JavaScript value that is not equal to itself.

var notANumber = NaN;
console.log(notANumber !== notANumber); // true

#4

This page helped me with NaN (and other falsey values) - https://www.sitepoint.com/javascript-truthy-falsy/

Use isNaN() instead of the case comparison.