Falsy Bouncer, filtering string

Falsy Bouncer, filtering string
0

#1

Tell us what’s happening:
It filters everything but also filters the string “ate” in the first test case and the “a”, “b”, “c” strings in the second.
Why does this filter the string in the array, I have been looking for an answer for hours?

Your code so far

function bouncer(arr) {
  // Don't show a false ID to this bouncer. 
  
  var item;
 
  return arr.filter(function(item) {

      return item !== false &&
        item !== null &&
        item !== 0 &&
        item !== "" &&
        item !== undefined && 
        !isNaN(item);
  });

  
}
bouncer([7, "ate", "", false, 9]);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36.

Link to the challenge:


#2

isNaN returns true if you passed it NaN, or any value that coerces to NaN (like most strings with letters in them).

There’s a better Number.isNaN() function that returns true if and only if you passed it NaN.


#3

also, you don’t need var item; statement. You can delete this.