1.0 KiB
1.0 KiB
id, title, challengeType, videoUrl
id | title | challengeType | videoUrl |
---|---|---|---|
adf08ec01beb4f99fc7a68f2 | Falsy Bouncer | 5 |
--description--
从数组中删除所有有价值的值。 JavaScript中的Falsy值为false
, null
, 0
, ""
, undefined
和NaN
。提示:尝试将每个值转换为布尔值。如果卡住,请记得使用Read-Search-Ask 。编写自己的代码。
--hints--
bouncer([7, "ate", "", false, 9])
应该返回[7, "ate", 9]
。
assert.deepEqual(bouncer([7, 'ate', '', false, 9]), [7, 'ate', 9]);
bouncer(["a", "b", "c"])
应返回["a", "b", "c"]
。
assert.deepEqual(bouncer(['a', 'b', 'c']), ['a', 'b', 'c']);
bouncer([false, null, 0, NaN, undefined, ""])
应返回[]
。
assert.deepEqual(bouncer([false, null, 0, NaN, undefined, '']), []);
bouncer([1, null, NaN, 2, undefined])
应该返回[1, 2]
。
assert.deepEqual(bouncer([null, NaN, 1, 2, undefined]), [1, 2]);