Falsy Bouncer algo help

Tell us what’s happening:
I can’t get Nan removed from the array . Help!

Your code so far


function bouncer(a) {
  // Don't show a false ID to this bouncer.
  let h = [];
  let s = [];
  for(let i = 0; i < a.length; i++){
    if(a[i] == false || a[i] == null || a[i] == 0||     a[i] == ""|| a[i] == undefined){
      h.push(i); 
    }
    
  }
  for(let j = (h.length)-1; j >= 0; j--){
    a.splice(h[j],1);
  }
  
 console.log(a);
}

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/falsy-bouncer/

The best way to check if a value is NaN is to check if your element is not equal to itself : see here

So add this condition to your array a[i] !== a[i] and it should work

However, there is a much simpler solution to this algorithm, I give you a hint by saying you can use the filter function :slight_smile: