--- id: adf08ec01beb4f99fc7a68f2 title: Falsy Bouncer isRequired: true challengeType: 5 forumTopicId: 16014 --- ## Description
Remove all falsy values from an array. Falsy values in JavaScript are false, null, 0, "", undefined, and NaN. Hint: Try converting each value to a Boolean. Remember to use Read-Search-Ask if you get stuck. Write your own code.
## Instructions
## Tests
```yml tests: - text: bouncer([7, "ate", "", false, 9]) should return [7, "ate", 9]. testString: assert.deepEqual(bouncer([7, "ate", "", false, 9]), [7, "ate", 9]); - text: bouncer(["a", "b", "c"]) should return ["a", "b", "c"]. testString: assert.deepEqual(bouncer(["a", "b", "c"]), ["a", "b", "c"]); - text: bouncer([false, null, 0, NaN, undefined, ""]) should return []. testString: assert.deepEqual(bouncer([false, null, 0, NaN, undefined, ""]), []); - text: bouncer([1, null, NaN, 2, undefined]) should return [1, 2]. testString: assert.deepEqual(bouncer([1, null, NaN, 2, undefined]), [1, 2]); ```
## Challenge Seed
```js function bouncer(arr) { // Don't show a false ID to this bouncer. return arr; } bouncer([7, "ate", "", false, 9]); ```
## Solution
```js function bouncer(arr) { return arr.filter(e => e); } bouncer([7, "ate", "", false, 9]); ```