* 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 | Falsy Bouncer | 5 | 16014 | falsy-bouncer |
--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.
--hints--
bouncer([7, "ate", "", false, 9])
should return [7, "ate", 9]
.
assert.deepEqual(bouncer([7, 'ate', '', false, 9]), [7, 'ate', 9]);
bouncer(["a", "b", "c"])
should return ["a", "b", "c"]
.
assert.deepEqual(bouncer(['a', 'b', 'c']), ['a', 'b', 'c']);
bouncer([false, null, 0, NaN, undefined, ""])
should return []
.
assert.deepEqual(bouncer([false, null, 0, NaN, undefined, '']), []);
bouncer([null, NaN, 1, 2, undefined])
should return [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]);