Tell us what’s happening:
I thought this will remove all falsy value from the array but it is only removing the first found falsy element not the rest after that.
Your code so far
function bouncer(arr) {
for(let i=0;i<arr.length;i++){
if(!arr[i]){
arr.splice(i,1);
}
}
console.log(arr)
return arr;
}
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/86.0.4240.75 Safari/537.36
.
Challenge: Falsy Bouncer
Link to the challenge: