Implement a Falsy Remover - Implement a Falsy Remover

Tell us what’s happening:

NaN from arr not excluded in FCC challenge falsy remover

Your code so far

const bouncer = arr => {
  let stack = []
  for (const reserved of arr) {
    // console.log(reserved)
    if (reserved !== false 
    && reserved !== null 
    && reserved !== 0 
    && reserved !== "" 
    && reserved !== undefined 
    && reserved !== NaN
    ) {
      stack.push(reserved)
    }
  }
  console.log(stack)
}
bouncer([false, null, 0, NaN, undefined, ""])

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Challenge Information:

Implement a Falsy Remover - Implement a Falsy Remover

There must be another way to detect NaN

There is a hint at the bottom of the instructions.

Ooh! I did not see that thanks.

1 Like

yeah, NaN === NaN is false. JS is funny like that