Tell us what’s happening:
This topic suggests converting the array values to boolean. I wasn’t sure how to do that, but I knew I could just check each value to see if it was a truthy and filter on that and so that’s what I did. Is this too simple a solution and if so did I miss the point of this exercise? (ps. how do I convert something to a boolean type?)
pps. to be perfectly clear, the code below passes the challenge, but it just seems too suspiciously easy.
Your code so far
function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(item => item);
}
bouncer([7, "ate", "", false, 9]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/falsy-bouncer