# I need an explaination (Falsy Bouncer)

Why the string does not come out and How can I remove NaN?

What the exercise is trying to teach you is that JavaScript has the concept of â€śtruthyâ€ť and â€śfalselyâ€ť values. When it converts (coerces) a value that isnâ€™t literally true or false to an actual true or false (a boolean), the language has rules for what it considers to be false: all of the values you are filtering out are considered false (0, false, null, undefined, NaN and an empty string '').

To fix what you have:

NaN is not equal to anything else, not even to itself. Think of it is a value that JS has been told is a number, but when JS tries to read it, it canâ€™t understand it. As it has no idea what it actually is, it canâ€™t say â€śthis unknown thing is the same as this other unknown thingâ€ť.

To check, you can simply do arr[i] !== arr[i], ie this value does not equal itself.

With the string, you can literally just do arr[i] !== ''. Also youâ€™ve misspelled string as strnig. You donâ€™t need to do typeof, you can just check it isnâ€™t an empty string, or isnâ€™t 0 or isnâ€™t null or whatever (except for NaN where you need to do what I suggested).

This solves it, but you donâ€™t need to do any of this: if you read back the first paragraph I wrote, about how JS has truthy and falsely values, you just need to check if the value is truthy or falsey.

There are much more concise ways to do this, but probably the easiest to inderstand is a function called Boolean(). If you give it a value, it converts it to true or false - Boolean(1) returns true, Boolean(null) returns false, Boolean('hello') returns true and so on.

1 Like