# Can't Eliminate null Values - Falsy Bouncer

**URL:** <https://forum.freecodecamp.org/t/cant-eliminate-null-values-falsy-bouncer/80281>\
**Category:** General\
**Created:** [January 25, 2017, 1:55am UTC](https://forum.freecodecamp.org/t/cant-eliminate-null-values-falsy-bouncer/80281 "2017-01-25T01:55:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Geist0504](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/geist0504/32/104587_2.png) [@Geist0504](https://forum.freecodecamp.org/u/Geist0504)\
**Post date:** [January 25, 2017, 1:55am UTC](https://forum.freecodecamp.org/t/cant-eliminate-null-values-falsy-bouncer/80281/1 "2017-01-25T01:55:55Z")

</div>

My below code works at removing all the values but null. Does anyone know why?

```auto
var falsey = [false, null, 0,"",undefined,NaN];

function remove(val){
  return falsey.indexOf(val) == -1;
}

function bouncer(arr) {
  var filtered = arr.filter(remove);
  return filtered;
}

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

```

---

<div class="post-metadata">

**Author:** ![uillianluiz](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/uillianluiz/32/163676_2.png) [@uillianluiz](https://forum.freecodecamp.org/u/uillianluiz)\
**Post date:** [January 25, 2017, 2:22am UTC](https://forum.freecodecamp.org/t/cant-eliminate-null-values-falsy-bouncer/80281/2 "2017-01-25T02:22:14Z")

</div>

Did you mean it doesn’t remove the NaN?  
Check this out:

```auto
null == null
true
NaN == NaN
false

```

It does not remove NaN because when the indexOf function does not find it in the array.

```auto
console.log(falsey.indexOf(NaN))
//logs -1

```

There is a function called `isNaN` that would return true in this case, more details [here](http://www.w3schools.com/jsref/jsref_isNaN.asp)

```auto
isNaN(NaN)
true

```

---

<div class="post-metadata">

**Author:** ![Geist0504](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/geist0504/32/104587_2.png) [@Geist0504](https://forum.freecodecamp.org/u/Geist0504)\
**Post date:** [January 25, 2017, 2:34am UTC](https://forum.freecodecamp.org/t/cant-eliminate-null-values-falsy-bouncer/80281/3 "2017-01-25T02:34:16Z")

</div>

You’re right! That was the issue. For some reason though, the console was returning the value to me as null not NaN. Any idea why?

---

<div class="post-metadata">

**Author:** ![ArielLeslie](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/arielleslie/32/264841_2.png) [@ArielLeslie](https://forum.freecodecamp.org/u/ArielLeslie)\
**Post date:** [January 25, 2017, 2:47pm UTC](https://forum.freecodecamp.org/t/cant-eliminate-null-values-falsy-bouncer/80281/4 "2017-01-25T14:47:04Z")

</div>

I’m going to be DRY and just link to yesterday’s discussion:

> **[Falsy Bouncer / NaN](https://forum.freecodecamp.org/t/falsy-bouncer-nan/80020/7)**
>
> I cleaned up your code. You need to use triple backticks to post code to the forum. See this post for details. This is a common misunderstanding with the Falsy Bouncer. You can make a solution for this challenge which tests against a hardcoded...

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 5:11pm UTC](https://forum.freecodecamp.org/t/cant-eliminate-null-values-falsy-bouncer/80281/5 "2021-01-16T17:11:13Z")

</div>

Closed on January 16, 2021, 5:11pm UTC


