2018-10-04 13:37:37 +00:00
---
id: 56533eb9ac21ba0edf2244d7
title: Comparison with the Less Than Or Equal To Operator
challengeType: 1
2019-02-14 17:24:02 +00:00
videoUrl: 'https://scrimba.com/c/cNVR7Am'
2019-07-31 18:32:23 +00:00
forumTopicId: 16788
2021-01-13 02:31:00 +00:00
dashedName: comparison-with-the-less-than-or-equal-to-operator
2018-10-04 13:37:37 +00:00
---
2020-11-27 18:02:05 +00:00
# --description--
2021-03-10 18:16:03 +00:00
The less than or equal to operator (`< =`) 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 `true` . If the number on the left is greater than the number on the right, it returns `false` . Like the equality operator, the less than or equal to operator converts data types.
2020-11-27 18:02:05 +00:00
**Examples**
2019-05-17 13:20:30 +00:00
```js
2021-03-03 00:12:12 +00:00
4 < = 5
'7' < = 7
5 < = 5
3 < = 2
'8' < = 4
2019-05-17 13:20:30 +00:00
```
2021-03-03 00:12:12 +00:00
In order, these expressions would evaluate to `true` , `true` , `true` , `false` , and `false` .
2020-11-27 18:02:05 +00:00
# --instructions--
2018-10-04 13:37:37 +00:00
2019-10-27 16:45:37 +00:00
Add the less than or equal to operator to the indicated lines so that the return statements make sense.
2018-10-04 13:37:37 +00:00
2020-11-27 18:02:05 +00:00
# --hints--
2021-03-03 00:12:12 +00:00
`testLessOrEqual(0)` should return the string `Smaller Than or Equal to 12`
2020-11-27 18:02:05 +00:00
```js
assert(testLessOrEqual(0) === 'Smaller Than or Equal to 12');
```
2021-03-03 00:12:12 +00:00
`testLessOrEqual(11)` should return the string `Smaller Than or Equal to 12`
2020-11-27 18:02:05 +00:00
```js
assert(testLessOrEqual(11) === 'Smaller Than or Equal to 12');
```
2021-03-03 00:12:12 +00:00
`testLessOrEqual(12)` should return the string `Smaller Than or Equal to 12`
2020-11-27 18:02:05 +00:00
```js
assert(testLessOrEqual(12) === 'Smaller Than or Equal to 12');
```
2021-03-03 00:12:12 +00:00
`testLessOrEqual(23)` should return the string `Smaller Than or Equal to 24`
2020-11-27 18:02:05 +00:00
```js
assert(testLessOrEqual(23) === 'Smaller Than or Equal to 24');
2018-10-04 13:37:37 +00:00
```
2021-03-03 00:12:12 +00:00
`testLessOrEqual(24)` should return the string `Smaller Than or Equal to 24`
2018-10-04 13:37:37 +00:00
2020-11-27 18:02:05 +00:00
```js
assert(testLessOrEqual(24) === 'Smaller Than or Equal to 24');
```
2018-10-04 13:37:37 +00:00
2021-03-03 00:12:12 +00:00
`testLessOrEqual(25)` should return the string `More Than 24`
2020-11-27 18:02:05 +00:00
```js
assert(testLessOrEqual(25) === 'More Than 24');
```
2021-03-03 00:12:12 +00:00
`testLessOrEqual(55)` should return the string `More Than 24`
2020-11-27 18:02:05 +00:00
```js
assert(testLessOrEqual(55) === 'More Than 24');
```
You should use the `<=` operator at least twice
```js
assert(code.match(/val\s*< =\s*('|")*\d+('|")*/g).length > 1);
```
# --seed--
## --seed-contents--
2018-10-04 13:37:37 +00:00
```js
function testLessOrEqual(val) {
if (val) { // Change this line
return "Smaller Than or Equal to 12";
}
2018-10-08 00:01:53 +00:00
2018-10-04 13:37:37 +00:00
if (val) { // Change this line
return "Smaller Than or Equal to 24";
}
return "More Than 24";
}
testLessOrEqual(10);
```
2020-11-27 18:02:05 +00:00
# --solutions--
2018-10-04 13:37:37 +00:00
```js
function testLessOrEqual(val) {
if (val < = 12) { // Change this line
return "Smaller Than or Equal to 12";
}
2018-10-08 00:01:53 +00:00
2018-10-04 13:37:37 +00:00
if (val < = 24) { // Change this line
return "Smaller Than or Equal to 24";
}
return "More Than 24";
}
```