Removing falsies from a string

Tell us what’s happening:

Why is my code not passing the challenge

Your code so far

function bouncer(arr) {
 var falsy=[false, "", null, undefined, 0, NaN];
 for(var j=0; j<falsy.length; j++){
 for(var i=0; i<arr.length; i++){
     let index=arr.indexOf(arr[i]);
     arr.splice(index, 1);
 return arr

console.log(bouncer([false, null, 0, NaN, undefined, ""]));

Your browser information:

User Agent is: Mozilla/5.0 (Linux; U; Android 7.0; TECNO P701 Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/87.0.4280.101 Mobile Safari/537.36 OPR/52.2.2254.54723.

Challenge: Falsy Bouncer

Link to the challenge:

on one side, NaN === NaN is false, on the other, changing the array on which you are iterating over has unintended consequences

I seem not to understand.
what do you suggest?

use the falsyness of the items instead of checking them one by own


if (null) {
   // this will not execute because null is falsy

also do not use splice on the array you are iterating on

Thank you so much. i will try it out