Tell us what’s happening:
Hi, I got stuck at one of the Algorithm Scripting challenges. It seems I chose a complicated way, because I wanted to iterate through an array with a loop and check whether neither of those has falsy values
Could you please advise me whether it will work or I should choose something else instead
Thank you in advance!
Your code so far
function bouncer(arr) {
// Don't show a false ID to this bouncer.
for (let i = 0; i < arr.length; i++) {
arr.filter(function() {arr[i] !== undefined || arr[i] !==null || arr[i] !==NaN || arr[i]!==0 || arr[i]!=="" || arr[i] !== false});
}
return arr;
}
bouncer([7, "ate", "", false, 9]);
Your browser information:
Chrome Version 75.0.3770.100 (Official Build) (64-bit)
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/falsy-bouncer