Everything be true, but why also NaN?

Everything be true, but why also NaN?
0.0 0


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) {
      case null:
      case undefined:
      case 0:
      case NaN:
      case '':
      case "":
        return false;
 return true;



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


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

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


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

Use isNaN() instead of the case comparison.