2018-10-10 18:03:03 -04:00
---
id: 56533eb9ac21ba0edf2244d5
2021-02-06 04:42:36 +00:00
title: Comparison with the Greater Than Or Equal To Operator
2018-10-10 18:03:03 -04:00
challengeType: 1
2020-04-29 18:29:13 +08:00
videoUrl: 'https://scrimba.com/c/c6KBqtV'
forumTopicId: 16785
2021-01-13 03:31:00 +01:00
dashedName: comparison-with-the-greater-than-or-equal-to-operator
2018-10-10 18:03:03 -04:00
---
2020-12-16 00:37:30 -07:00
# --description--
2021-02-06 04:42:36 +00:00
The greater than or equal to operator (`>=` ) compares the values of two numbers. If the number to the left is greater than or equal to the number to the right, it returns `true` . Otherwise, it returns `false` .
2020-12-16 00:37:30 -07:00
2021-02-06 04:42:36 +00:00
Like the equality operator, `greater than or equal to` operator will convert data types while comparing.
2020-12-16 00:37:30 -07:00
2021-02-06 04:42:36 +00:00
**Examples**
2020-04-29 18:29:13 +08:00
```js
6 >= 6 // true
7 >= '3' // true
2 >= 3 // false
'7' >= 9 // false
```
2020-12-16 00:37:30 -07:00
# --instructions--
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
Add the greater than or equal to operator to the indicated lines so that the return statements make sense.
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
# --hints--
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
`testGreaterOrEqual(0)` should return "Less than 10"
2018-10-10 18:03:03 -04:00
```js
2020-12-16 00:37:30 -07:00
assert(testGreaterOrEqual(0) === 'Less than 10');
```
2021-02-06 04:42:36 +00:00
`testGreaterOrEqual(9)` should return "Less than 10"
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(testGreaterOrEqual(9) === 'Less than 10');
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
`testGreaterOrEqual(10)` should return "10 or Over"
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(testGreaterOrEqual(10) === '10 or Over');
2018-10-10 18:03:03 -04:00
```
2021-02-06 04:42:36 +00:00
`testGreaterOrEqual(11)` should return "10 or Over"
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(testGreaterOrEqual(11) === '10 or Over');
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
`testGreaterOrEqual(19)` should return "10 or Over"
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(testGreaterOrEqual(19) === '10 or Over');
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
`testGreaterOrEqual(100)` should return "20 or Over"
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(testGreaterOrEqual(100) === '20 or Over');
```
2021-02-06 04:42:36 +00:00
`testGreaterOrEqual(21)` should return "20 or Over"
2020-04-29 18:29:13 +08:00
2018-10-10 18:03:03 -04:00
```js
2020-12-16 00:37:30 -07:00
assert(testGreaterOrEqual(21) === '20 or Over');
```
2020-04-29 18:29:13 +08:00
2021-02-06 04:42:36 +00:00
You should use the `>=` operator at least twice
2020-04-29 18:29:13 +08:00
2020-12-16 00:37:30 -07:00
```js
assert(code.match(/val\s*>=\s*('|")*\d+('|")*/g).length > 1);
2018-10-10 18:03:03 -04:00
```
2020-04-29 18:29:13 +08:00
2021-01-13 03:31:00 +01:00
# --seed--
## --seed-contents--
```js
function testGreaterOrEqual(val) {
if (val) { // Change this line
return "20 or Over";
}
if (val) { // Change this line
return "10 or Over";
}
return "Less than 10";
}
testGreaterOrEqual(10);
```
2020-12-16 00:37:30 -07:00
# --solutions--
2021-01-13 03:31:00 +01:00
```js
function testGreaterOrEqual(val) {
if (val >= 20) { // Change this line
return "20 or Over";
}
if (val >= 10) { // Change this line
return "10 or Over";
}
return "Less than 10";
}
```