Everything Be True - helped needed with NaN!

Everything Be True - helped needed with NaN!
0

#1

This is what I have. It passes on everything except the last one where the value for the object is NaN.

` function truthCheck(collection, pre) {
// Is everyone being true?
var counter = 0;

  for(var i=0; i<collection.length;i++) {
    if (collection[i].hasOwnProperty(pre)  && collection[i][pre] !== null && collection[i][pre] !== "" && collection[i][pre] !== 0 && collection[i][pre] !== undefined && typeof collection[i][pre] !== NaN) {
      counter++;
    }
  }
    
  return (counter === collection.length);
} `

How can I write NaN. The text editor suggests using isNaN() but i can’t get it working in the editor. Any ideas?


#3

You don’t have to check every condition yourself, just leave collection[i][pre] and js will check if it is trythy for you:

if (collection[i].hasOwnProperty(pre) && collection[i][pre]) {
  ...