I know this can be solved very easily using .filter but am trying to practise .splice
I thought the below would do the trick but for some reason this will only remove the first falsy value in the array?
Your code so far
function bouncer(arr) {
for (let i = 0 ; i<arr.length ; i++) {
if(!arr[i]) {
arr.splice( arr.indexOf(arr[i]) , 1)
}
}
return arr;
}
bouncer([7, "ate",false, "", 9]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36.
Link to the challenge: