When you are so explicit with the falsy values, you miss the point of the challenge. which is to show that things that have certain values will evaluate to false in a boolean context.
just to add a bit more to what @zapcannon99 is saying,
true and false are both boolean values but
a ‘falsy’ is value that is not Boolean but still evaluates to false (in boolean context), eg. 0
a ‘truthy’ is a value is not Boolean but still evaluates to true (in boolean context), eg. 1
Removing all falsy values from an array = return all truthy values.
The filter() method creates a new array with all elements that pass the test implemented by the provided function. (MDN definition)
If .filter() method is properly implemented, you’ll return only those values which return true in the Boolean context – thus solving the challenge in one line
function bouncer(arr) {
// Don’t show a false ID to this bouncer.
filteredArr = [false, null, 0, “”, undefined, NaN].filter(bouncer, !arr, !arr.length);
return filteredArr;
}
bouncer([7, “ate”, “”, false, 9]);
I got Maximum call size stack exceeded. Really need some assistance. Thank you