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