Because 'ate', 'a', 'b', 'c' pass the isNaN(value) and returns true. Therefore is not returning undefined. Your code pushes all the undefined from isPositive function. So all the strings doesn’t get pushed
Notice that isNaN means is Not a Number, those are strings. String is Not a Number
Hi I think your code is over-creative . It might be simpler if you just go ahead and return true values.
But we still can use your code. Though it’s a bit theoretical. You might want to read about NaN - JavaScript.
Notice that
NaN === NaN; // false
Therefore instead of isNaN(value) we can use
val !== val
Because
NaN !== NaN returns true
Edit: This is in JavaScript, it may be different in other language. Sooo in the end i still suggest for writing a simpler code. We can easily bounce the falsy value by ignoring every false value and pushing every true value