I am having trouble understanding isNaN function. I wrote some code that seems to be working,but the part where I have the isNaN function as an if statement does not work the way I want it to. And I am really not sure if the code is just assuming that the isNaN(collection[i][pre]) part sees the collection[i][pre] as something that is just not a Number,and not something that returns a NaN. Not really sure if what I wrote actually makes sense . Anyway,what seems to be the problem here and is there another way for me to describe the part of the code concerning falsy values?
function truthCheck(collection, pre) {
var counter = 0;
var special = 0;
for (var i = 0; i < collection.length; i++) {
if (collection[i][pre] === null || collection[i][pre] === 0 || collection[i][pre] === undefined || collection[i][pre] === "" || isNaN(collection[i][pre]) ) {return false;}
else {
if (collection[i].hasOwnProperty(pre)) {counter += 0;}
else {counter += 1;}
}
}
if (counter === 0) {return true;}
return false;
}
truthCheck([{"single": "yes"}], "single"); // it returns false