Problem with a challenge... Falsy Bouncer

I got the following solution for the Falsy, and it does return the proper responses, but it still shows a failing response. Don’t know why… can any body tell me please?

the challenge is to Remove all falsy values from an array.

Falsy values in JavaScript are false, null, 0, “”, undefined, and NaN.

Here is the code I came up with:

var cleanArr=[];
var notAccepted = [false, 0, “”, undefined, NaN];
var isFound = false;

function searchArray(srchStr, obj) {
for(var i=0; i<srchStr.length; i++) {
if (srchStr[i] == obj) return true;

function bouncer(arr) {
// Don’t show a false ID to this bouncer.
for (var i=0; i<arr.length+1; i++) {
if (searchArray(notAccepted, arr[i]) != true && arr[i] == arr[i]) {
// Since NaN is the only JavaScript value that is treated as unequal to itself, you can always test if a value is NaN by checking it for equality to itself:


return cleanArr;

bouncer([1, null, NaN, 2, undefined]);

No problemo. You just have to cut your variables and put them in the bouncer function, they’ll still be available to the other function since that function is called from inside of bouncer().

The tests are being called one after the other, and if your variables aren’t inside a function their values carry over to the next test skewing the results.

Thanks for the explanation…