dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
112 lines
2.5 KiB
Markdown
112 lines
2.5 KiB
Markdown
---
|
|
id: 56533eb9ac21ba0edf2244d7
|
|
title: Comparison with the Less Than Or Equal To Operator
|
|
challengeType: 1
|
|
forumTopicId: 16788
|
|
dashedName: comparison-with-the-less-than-or-equal-to-operator
|
|
---
|
|
|
|
# --description--
|
|
|
|
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.
|
|
|
|
**Examples**
|
|
|
|
```js
|
|
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`
|
|
|
|
```js
|
|
assert(testLessOrEqual(0) === 'Smaller Than or Equal to 12');
|
|
```
|
|
|
|
`testLessOrEqual(11)` should return the string `Smaller Than or Equal to 12`
|
|
|
|
```js
|
|
assert(testLessOrEqual(11) === 'Smaller Than or Equal to 12');
|
|
```
|
|
|
|
`testLessOrEqual(12)` should return the string `Smaller Than or Equal to 12`
|
|
|
|
```js
|
|
assert(testLessOrEqual(12) === 'Smaller Than or Equal to 12');
|
|
```
|
|
|
|
`testLessOrEqual(23)` should return the string `Smaller Than or Equal to 24`
|
|
|
|
```js
|
|
assert(testLessOrEqual(23) === 'Smaller Than or Equal to 24');
|
|
```
|
|
|
|
`testLessOrEqual(24)` should return the string `Smaller Than or Equal to 24`
|
|
|
|
```js
|
|
assert(testLessOrEqual(24) === 'Smaller Than or Equal to 24');
|
|
```
|
|
|
|
`testLessOrEqual(25)` should return the string `More Than 24`
|
|
|
|
```js
|
|
assert(testLessOrEqual(25) === 'More Than 24');
|
|
```
|
|
|
|
`testLessOrEqual(55)` should return the string `More Than 24`
|
|
|
|
```js
|
|
assert(testLessOrEqual(55) === 'More Than 24');
|
|
```
|
|
|
|
You should use the `<=` operator at least twice
|
|
|
|
```js
|
|
assert(__helpers.removeJSComments(code).match(/val\s*<=\s*('|")*\d+('|")*/g).length > 1);
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```js
|
|
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--
|
|
|
|
```js
|
|
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";
|
|
}
|
|
```
|