Falsy Bouncer what's wrong?

Falsy Bouncer what's wrong?
0.0 0

#1

/*
function bouncer(arr) {
// Don’t show a false ID to this bouncer.
function filtered(newArr){
newArr=arr;
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.


#2

@Woldemar1086

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.


#3

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

[details=spoilers]
//stuff
[/details]

#4

Thanks @PortableStick I changed it.


#5

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?


#6

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

But it didn’t work anyway.


#7

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.


#8

yeah,that’s true.Thanks.


#9

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