Not satisfied with Falsy Bouncer official solution

The Get a Hint solution to Falsy Bouncer is:

function bouncer(arr) {
    return arr.filter(Boolean);

However… arr.filter(Boolean) would also filter true values, therefor the solution provided by freeCodeCamp seems…lazy or incomplete.

I’m noticing the given solutions to many algorithm challenges are incorrect. This is extremely frustrating as a beginner who tries and tries, then turns to an official solution only to find it either doesn’t pass the challenge or wouldn’t pass under different tests.


It could be clearer. I guess they expect you to realize (or research) that by Boolean they mean a callback function that returns a boolean.

1 Like

It would keep true values as truthy, which is the point of the exercise, I’m not sure why you think it’s incorrect? Given an array of truthy and falsey values, arr.filter(Boolean) will keep the truthy values, by passing the function Boolean as the argument to filter

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

You can post solutions that invite discussion (like asking how the solution works, or asking about certain parts of the solution). But please don’t just post your solution for the sake of sharing it.
If you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.