1.9 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			1.9 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
'3' < 7
5   < 5
3   < 2
'8' < 4
按順序,這些表達式會返回 true、true、false、false 和 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";
}