2018-10-04 14:37:37 +01:00
---
id: 56533eb9ac21ba0edf2244d7
title: Comparison with the Less Than Or Equal To Operator
challengeType: 1
2019-02-14 12:24:02 -05:00
videoUrl: 'https://scrimba.com/c/cNVR7Am'
2019-07-31 11:32:23 -07:00
forumTopicId: 16788
2018-10-04 14:37:37 +01:00
---
## Description
<section id='description'>
The <code>less than or equal to</code> operator (<code><=</code>) compares the values of two numbers. If the number to the left is less than or equal to the number to the right, it returns <code>true</code>. If the number on the left is greater than the number on the right, it returns <code>false</code>. Like the equality operator, <code>less than or equal to</code> converts data types.
<strong>Examples</strong>
2019-05-17 06:20:30 -07:00
```js
4 <= 5 // true
'7' <= 7 // true
5 <= 5 // true
3 <= 2 // false
'8' <= 4 // false
```
2018-10-04 14:37:37 +01:00
</section>
## Instructions
<section id='instructions'>
Add the <code>less than or equal to</code> operator to the indicated lines so that the return statements make sense.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>testLessOrEqual(0)</code> should return "Smaller Than or Equal to 12"
2019-07-13 00:07:53 -07:00
testString: assert(testLessOrEqual(0) === "Smaller Than or Equal to 12");
2018-10-04 14:37:37 +01:00
- text: <code>testLessOrEqual(11)</code> should return "Smaller Than or Equal to 12"
2019-07-13 00:07:53 -07:00
testString: assert(testLessOrEqual(11) === "Smaller Than or Equal to 12");
2018-10-04 14:37:37 +01:00
- text: <code>testLessOrEqual(12)</code> should return "Smaller Than or Equal to 12"
2019-07-13 00:07:53 -07:00
testString: assert(testLessOrEqual(12) === "Smaller Than or Equal to 12");
2018-10-04 14:37:37 +01:00
- text: <code>testLessOrEqual(23)</code> should return "Smaller Than or Equal to 24"
2019-07-13 00:07:53 -07:00
testString: assert(testLessOrEqual(23) === "Smaller Than or Equal to 24");
2018-10-04 14:37:37 +01:00
- text: <code>testLessOrEqual(24)</code> should return "Smaller Than or Equal to 24"
2019-07-13 00:07:53 -07:00
testString: assert(testLessOrEqual(24) === "Smaller Than or Equal to 24");
2018-10-04 14:37:37 +01:00
- text: <code>testLessOrEqual(25)</code> should return "More Than 24"
2019-07-13 00:07:53 -07:00
testString: assert(testLessOrEqual(25) === "More Than 24");
2018-10-04 14:37:37 +01:00
- text: <code>testLessOrEqual(55)</code> should return "More Than 24"
2019-07-13 00:07:53 -07:00
testString: assert(testLessOrEqual(55) === "More Than 24");
2018-10-04 14:37:37 +01:00
- text: You should use the <code><=</code> operator at least twice
2019-07-13 00:07:53 -07:00
testString: assert(code.match(/val\s*<=\s*('|")*\d+('|")*/g).length > 1);
2018-10-04 14:37:37 +01:00
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function testLessOrEqual(val) {
if (val) { // Change this line
return "Smaller Than or Equal to 12";
}
2018-10-08 01:01:53 +01:00
2018-10-04 14:37:37 +01:00
if (val) { // Change this line
return "Smaller Than or Equal to 24";
}
return "More Than 24";
}
// Change this value to test
testLessOrEqual(10);
```
</div>
</section>
## Solution
<section id='solution'>
```js
function testLessOrEqual(val) {
if (val <= 12) { // Change this line
return "Smaller Than or Equal to 12";
}
2018-10-08 01:01:53 +01:00
2018-10-04 14:37:37 +01:00
if (val <= 24) { // Change this line
return "Smaller Than or Equal to 24";
}
return "More Than 24";
}
```
</section>