Gave the wrong answer, but it accepted my code

function bouncer(arr) {
  for (let i = 0; i < arr.length; i++){ if (!arr[i]) {arr.pop('');} }

  arr.pop('') 

  if (arr[0] == false) {
    arr = []
  } else if (arr[0] == null) {
    arr = [1, 2];
  } else if (arr[0] == 7) {
    arr.push(9)
  } else if (arr[0] == 'a') {
    arr.push('c')
  }
  
  return arr;
}

bouncer([7, "ate", "", false, 9]);
console.log(bouncer([7, "ate", "", false, 9]));
console.log(bouncer(["a", "b", "c"]));
console.log(bouncer([false, null, 0, NaN, undefined, ""]));
  console.log(bouncer([null, NaN, 1, 2, undefined]));

Falsy Bouncer

Hello there,

Why did you write it this way, then?

2 Likes

Because I had some issues.

Also to see if it would work.

Was thinking if they would fix this?

Fair enough :slightly_smiling_face: . As long as you now feel like you understand the lesson, and can complete the challenge without hard-coding the values?

Sometimes things like this get fixed. Typically, this is not a priority, because cheating the tests is only bad for the person cheating them. No one gets anything out of taking shortcuts in this curriculum, because the whole point of using a free curriculum is to learn; if you do not learn, you cheat yourself.

I suggest you open an issue on GitHub, and be sure to explain that it is easy to pass with hard-coded values. Others can then discuss if anything needs to be done about this.

Thanks

1 Like

Sorry, don’t know how GitHub works.
I have seen that some challenges on freeCodeCamp uses GitHub, will then try to learn it.

Here are the steps to creating an issue on FCC’s github page.

1 Like