2.7 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--
Add the less than or equal to operator to the indicated lines so that the return statements make sense.
--hints--
testLessOrEqual(0) should return the string Smaller Than or Equal to 12
assert(testLessOrEqual(0) === 'Smaller Than or Equal to 12');
testLessOrEqual(11) should return the string Smaller Than or Equal to 12
assert(testLessOrEqual(11) === 'Smaller Than or Equal to 12');
testLessOrEqual(12) should return the string Smaller Than or Equal to 12
assert(testLessOrEqual(12) === 'Smaller Than or Equal to 12');
testLessOrEqual(23) should return the string Smaller Than or Equal to 24
assert(testLessOrEqual(23) === 'Smaller Than or Equal to 24');
testLessOrEqual(24) should return the string Smaller Than or Equal to 24
assert(testLessOrEqual(24) === 'Smaller Than or Equal to 24');
testLessOrEqual(25) should return the string More Than 24
assert(testLessOrEqual(25) === 'More Than 24');
testLessOrEqual(55) should return the string More Than 24
assert(testLessOrEqual(55) === 'More Than 24');
You should use the <= operator at least twice
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";
}