Falsy Bouncer what's wrong?

function bouncer(arr) {
// Don’t show a false ID to this bouncer.
function filtered(newArr){
for (var i=0;i<newArr.length;i++){
return newArr[i]!==0||newArr[i]!==false||newArr[i]!==null||newArr[i]!==""||newArr[i]!==undefined;
//undefined is equal to NaN and equal to undefined
return arr.filter(filtered);

bouncer([7, “ate”, “”, false, 9]);

Can anyone explane me, what i did wrong? The logic is so:
we check every value in Array through the Loop. There is if statement, which should return false or the value if it’s true, and in the end we become Array arr with false and values if the answer to our conditions.


The easiest way I found to do this challenge is to filter on the Boolean function.

The Boolean method will take each value of the array as an argument and then evaluate it as true or false. Any “falsy” value will return false and thus be filtered.

Hopefully this helps.

I don’t know why it’s not letting me edit your post, but please don’t post full solutions when someone is just asking for help. If you do include a working solution in your post, please include spoiler tags


Thanks @PortableStick I changed it.

1 Like

There’s a couple of problems with your logic. One is that comment stating NaN is equal to undefined.

Also, you’ve got a return statement inside of a for loop. Think about what happens when we return something from a for loop. How far into the loop do we get?

I’m sorry. Next time i will do with “Spoilers”

But it didn’t work anyway.

Yeah, i know, but this why also should work. And i did some mistake in code. I just want to find solving in this why.

yeah,that’s true.Thanks.

You’re fine. That comment was directed at dpberry, not you.