2.5 KiB
2.5 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
56533eb9ac21ba0edf2244d6 | Comparison with the Less Than Operator | 1 | 与小于算子的比较 |
Description
<
)比较两个数字的值。如果左边的数字小于右边的数字,则返回true
。否则,它返回false
。与等于运算符一样, 少于运算符在比较时转换数据类型。 例子 2 <5 //是的
'3'<7 //是的
5 <5 //假
3 <2 //假
'8'<4 //假
Instructions
less than
运算符添加到指示的行,以便返回语句有意义。 Tests
tests:
- text: <code>testLessThan(0)</code>应该返回“25岁以下”
testString: 'assert(testLessThan(0) === "Under 25", "<code>testLessThan(0)</code> should return "Under 25"");'
- text: <code>testLessThan(24)</code>应该返回“25岁以下”
testString: 'assert(testLessThan(24) === "Under 25", "<code>testLessThan(24)</code> should return "Under 25"");'
- text: <code>testLessThan(25)</code>应该返回“55岁以下”
testString: 'assert(testLessThan(25) === "Under 55", "<code>testLessThan(25)</code> should return "Under 55"");'
- text: <code>testLessThan(54)</code>应该返回“55岁以下”
testString: 'assert(testLessThan(54) === "Under 55", "<code>testLessThan(54)</code> should return "Under 55"");'
- text: <code>testLessThan(55)</code>应返回“55或以上”
testString: 'assert(testLessThan(55) === "55 or Over", "<code>testLessThan(55)</code> should return "55 or Over"");'
- text: <code>testLessThan(99)</code>应返回“55或以上”
testString: 'assert(testLessThan(99) === "55 or Over", "<code>testLessThan(99)</code> should return "55 or Over"");'
- text: 您应该至少使用<code><</code>运算符两次
testString: 'assert(code.match(/val\s*<\s*("|")*\d+("|")*/g).length > 1, "You should use the <code><</code> operator at least twice");'
Challenge Seed
function testLessThan(val) {
if (val) { // Change this line
return "Under 25";
}
if (val) { // Change this line
return "Under 55";
}
return "55 or Over";
}
// Change this value to test
testLessThan(10);
Solution
// solution required