* 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.8 KiB
1.8 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
id | title | challengeType | videoUrl | forumTopicId | dashedName |
---|---|---|---|---|---|
56533eb9ac21ba0edf2244d6 | 小于运算符 | 1 | https://scrimba.com/c/cNVRWtB | 16789 | comparison-with-the-less-than-operator |
--description--
使用小于运算符(<
)比较两个数字的大小。如果小于运算符左边的数字比右边的数字小,它会返回true
。否则会返回false
。与相等运算符类似,小于 运算符在做比较的时候会转换值的数据类型。
例如
2 < 5 // true
'3' < 7 // true
5 < 5 // false
3 < 2 // false
'8' < 4 // false
--instructions--
添加小于
运算符到指定行,使得函数的返回语句有意义。
--hints--
testLessThan(0)
应该返回 "Under 25"。
assert(testLessThan(0) === 'Under 25');
testLessThan(24)
应该返回 "Under 25"。
assert(testLessThan(24) === 'Under 25');
testLessThan(25)
应该返回 "Under 55"。
assert(testLessThan(25) === 'Under 55');
testLessThan(54)
应该返回 "Under 55"。
assert(testLessThan(54) === 'Under 55');
testLessThan(55)
应该返回 "55 or Over"。
assert(testLessThan(55) === '55 or Over');
testLessThan(99)
应该返回 "55 or Over"。
assert(testLessThan(99) === '55 or Over');
你应该使用<
运算符至少两次。
assert(code.match(/val\s*<\s*('|")*\d+('|")*/g).length > 1);
--seed--
--seed-contents--
function testLessThan(val) {
if (val) { // Change this line
return "Under 25";
}
if (val) { // Change this line
return "Under 55";
}
return "55 or Over";
}
testLessThan(10);
--solutions--
function testLessThan(val) {
if (val < 25) { // Change this line
return "Under 25";
}
if (val < 55) { // Change this line
return "Under 55";
}
return "55 or Over";
}