Hi, do I need to initialize what a falsey variable is or is arr == true enough to know what it has to be?
I tried two different approaches so far but none are working:
1st try
var newArr = []; // initialize to store result
for (let i = 0; i < arr.length; i++) { // loop through arr
if (arr[i] == true) { // if its not falsey
newArr.push([i]); //push to newArr
}
}
return newArr;
}
second try
function bouncer(arr) {
return arr.filter([arr == true]) // hint says to use filter and this is what I got from looking at Mozilla docs
}
console.log(bouncer([7, "ate", "", false, 9]));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36
.
Challenge: Falsy Bouncer
Link to the challenge: