2018-10-04 14:37:37 +01:00
---
id: 56533eb9ac21ba0edf2244d5
title: Comparison with the Greater Than Or Equal To Operator
challengeType: 1
2019-02-14 12:24:02 -05:00
videoUrl: 'https://scrimba.com/c/c6KBqtV'
2019-07-31 11:32:23 -07:00
forumTopicId: 16785
2018-10-04 14:37:37 +01:00
---
## Description
< section id = 'description' >
The < code > greater than or equal to< / code > operator (< code > > =< / code > ) 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 < code > true< / code > . Otherwise, it returns < code > false< / code > .
Like the equality operator, < code > greater than or equal to< / code > operator will convert data types while comparing.
< strong > Examples< / strong >
2019-05-17 06:20:30 -07:00
```js
6 >= 6 // true
7 >= '3' // true
2 >= 3 // false
'7' >= 9 // false
```
2018-10-04 14:37:37 +01:00
< / section >
## Instructions
< section id = 'instructions' >
Add the < code > greater 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 > testGreaterOrEqual(0)</ code > should return "Less than 10"
2019-07-13 00:07:53 -07:00
testString: assert(testGreaterOrEqual(0) === "Less than 10");
2018-10-04 14:37:37 +01:00
- text: < code > testGreaterOrEqual(9)</ code > should return "Less than 10"
2019-07-13 00:07:53 -07:00
testString: assert(testGreaterOrEqual(9) === "Less than 10");
2018-10-04 14:37:37 +01:00
- text: < code > testGreaterOrEqual(10)</ code > should return "10 or Over"
2019-07-13 00:07:53 -07:00
testString: assert(testGreaterOrEqual(10) === "10 or Over");
2018-10-04 14:37:37 +01:00
- text: < code > testGreaterOrEqual(11)</ code > should return "10 or Over"
2019-07-13 00:07:53 -07:00
testString: assert(testGreaterOrEqual(11) === "10 or Over");
2018-10-04 14:37:37 +01:00
- text: < code > testGreaterOrEqual(19)</ code > should return "10 or Over"
2019-07-13 00:07:53 -07:00
testString: assert(testGreaterOrEqual(19) === "10 or Over");
2018-10-04 14:37:37 +01:00
- text: < code > testGreaterOrEqual(100)</ code > should return "20 or Over"
2019-07-13 00:07:53 -07:00
testString: assert(testGreaterOrEqual(100) === "20 or Over");
2018-10-04 14:37:37 +01:00
- text: < code > testGreaterOrEqual(21)</ code > should return "20 or Over"
2019-07-13 00:07:53 -07:00
testString: assert(testGreaterOrEqual(21) === "20 or Over");
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 testGreaterOrEqual(val) {
if (val) { // Change this line
return "20 or Over";
}
2018-10-08 01:01:53 +01:00
2018-10-04 14:37:37 +01:00
if (val) { // Change this line
return "10 or Over";
}
return "Less than 10";
}
// Change this value to test
testGreaterOrEqual(10);
```
< / div >
< / section >
## Solution
< section id = 'solution' >
```js
function testGreaterOrEqual(val) {
if (val >= 20) { // Change this line
return "20 or Over";
}
2018-10-08 01:01:53 +01:00
2018-10-04 14:37:37 +01:00
if (val >= 10) { // Change this line
return "10 or Over";
}
return "Less than 10";
}
```
< / section >