Falsy Bouncer / Help

Tell us what’s happening:

Confusion about where I’m going wrong. I thought the i-- would take care of the glitch.

Your code so far


function bouncer(arr) {

for(let i = 0; i < arr.length; i++) {
  if(!arr[i]) {
    arr.splice(i);
    i--;
  }
}

console.log(arr);
return arr;

}

bouncer([7, "ate", "", false, 9]); 
// gives the result [7, "ate"] instead of [7, "ate", 9]

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15.

Challenge: Falsy Bouncer

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/falsy-bouncer

Got it. Telling the splice function to remove just one element per round did the trick.