* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
1.1 KiB
1.1 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
adf08ec01beb4f99fc7a68f2 | 过滤数组中的假值 | 5 | 16014 | falsy-bouncer |
--description--
从数组中移除所有假值(falsy values)。
JavaScript 中的假值有 false
、null
、0
、""
、undefined
、NaN
。
提示:可以考虑将每个值都转换为布尔值(boolean)。
--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]);
--seed--
--seed-contents--
function bouncer(arr) {
return arr;
}
bouncer([7, "ate", "", false, 9]);
--solutions--
function bouncer(arr) {
return arr.filter(e => e);
}
bouncer([7, "ate", "", false, 9]);