--- id: adf08ec01beb4f99fc7a68f2 title: Falsy Bouncer isRequired: true challengeType: 5 videoUrl: '' localeTitle: Falsy Bouncer --- ## Description
从数组中删除所有有价值的值。 JavaScript中的Falsy值为falsenull0""undefinedNaN 。提示:尝试将每个值转换为布尔值。如果卡住,请记得使用Read-Search-Ask 。编写自己的代码。
## Instructions
## Tests
```yml tests: - text: 'bouncer([7, "ate", "", false, 9])应该返回[7, "ate", 9] 。' testString: 'assert.deepEqual(bouncer([7, "ate", "", false, 9]), [7, "ate", 9], "bouncer([7, "ate", "", false, 9]) should return [7, "ate", 9].");' - text: 'bouncer(["a", "b", "c"])应返回["a", "b", "c"] 。' testString: 'assert.deepEqual(bouncer(["a", "b", "c"]), ["a", "b", "c"], "bouncer(["a", "b", "c"]) should return ["a", "b", "c"].");' - text: 'bouncer([false, null, 0, NaN, undefined, ""])应返回[] 。' testString: 'assert.deepEqual(bouncer([false, null, 0, NaN, undefined, ""]), [], "bouncer([false, null, 0, NaN, undefined, ""]) should return [].");' - text: 'bouncer([1, null, NaN, 2, undefined])应该返回[1, 2] 。' testString: 'assert.deepEqual(bouncer([1, null, NaN, 2, undefined]), [1, 2], "bouncer([1, null, NaN, 2, undefined]) should return [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 // solution required ```