Hi there! I’m so lost with 4 of the Basic Algorithm Scripting. This one seems to be a bit too technical so maybe I’m misunderstanding the Boolean() function or the falsy values or both. I basically though that the if condition will delete the array’s entry if it’s false. (That did work with just the array passed [“a”, “b”, “c”] but not with the others and I’m not getting why. I saw the two solutions and I understood them but they didn’t cleared why my algorithm is not working. Thanks in advance!
Your code so far
function bouncer(arr) {
for (let i = 0; i<arr.length; i++){
if (Boolean(arr[i]) === false) {
arr.splice(i, 1);
}
}
return arr;
}
bouncer([7, "ate", "", false, 9]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0
.
Challenge: Falsy Bouncer
Link to the challenge: