Basic Algorithm Scripting - Falsy Bouncer

Tell us what’s happening:
Describe your issue in detail here.
Why is this not working??
I tried to remove it in some other ways, but this one is the most straightforward to make sure that it will work, but it does not
I create an empty array and push when an item of the array given in the argument of the function is not “falsy”
I think I need better feedback on what is wrong, especially if I mistyped something.

The exercise wants us to remove “falsy” values from an array.
But besides that, it is complaining that what is returned is not the correct array and I doubt the problem it has is that it’s not actually changing the passed array.
Your code so far

function bouncer(arr) {
  res = [];
  for(let index = 0; index < arr.length; ++index){
    if(Boolean(arr[index])){
      res.push(arr[index]);
    }
  }
  return res;
}

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/105.0.0.0 Safari/537.36

Challenge: Basic Algorithm Scripting - Falsy Bouncer

Link to the challenge:

You should see a big error complaining that you never declared this variable.

1 Like

Tell us what’s happening:
Describe your issue in detail here.
Never mind, I just didn’t realize for quite some time that when I make a mistake, it will give some errors(ref is undefined…) I am not familiar with this forum at all, I don’t know how to delete it…
Your code so far

function bouncer(arr) {
  let res = [];
  for(let index = 0; index < arr.length; ++index){
    if(Boolean(arr[index])){
      res.push(arr[index]);
    }
  }
  return res;
}

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/105.0.0.0 Safari/537.36

Challenge: Basic Algorithm Scripting - Falsy Bouncer

Link to the challenge:

I did once I remembered to check if it complains about something… thank you!
For some reason it didn’t occur to me to check for so long…

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