Basic Algorithm Scripting - Falsy Bouncer

Tell us what’s happening:
How does condition “if” passing new array works? kinda confused a bit, I just copied code from hint

Your code so far

function bouncer(arr) {
  const filterRR = [];
  for (let i = 0; i < arr.length; i++) {
    if (arr[i]) filterRR.push(arr[i]);
  }
  return filterRR;
}
  
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/114.0.0.0 Safari/537.36

Challenge: Basic Algorithm Scripting - Falsy Bouncer

Link to the challenge:

image

Try enter this into your code and see what prints out :heart:

1 Like

The if statement checks for truthiness.

1 Like

Thank you I will try it! I’m just confused of line 4 if condition

Thank you for the explanation sir.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.