2018-10-04 13:37:37 +00:00
---
id: 56533eb9ac21ba0edf2244d4
title: Comparison with the Greater Than Operator
challengeType: 1
2019-02-14 17:24:02 +00:00
videoUrl: 'https://scrimba.com/c/cp6GbH4'
2019-07-31 18:32:23 +00:00
forumTopicId: 16786
2018-10-04 13:37:37 +00:00
---
2020-11-27 18:02:05 +00:00
# --description--
The greater than operator (`>`) compares the values of two numbers. If the number to the left is greater than the number to the right, it returns `true` . Otherwise, it returns `false` .
2018-10-04 13:37:37 +00:00
Like the equality operator, greater than operator will convert data types of values while comparing.
2020-11-27 18:02:05 +00:00
**Examples**
2019-05-17 13:20:30 +00:00
```js
5 > 3 // true
7 > '3' // true
2 > 3 // false
'1' > 9 // 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 greater than 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--
`testGreaterThan(0)` should return "10 or Under"
```js
assert(testGreaterThan(0) === '10 or Under');
```
`testGreaterThan(10)` should return "10 or Under"
```js
assert(testGreaterThan(10) === '10 or Under');
```
`testGreaterThan(11)` should return "Over 10"
```js
assert(testGreaterThan(11) === 'Over 10');
```
`testGreaterThan(99)` should return "Over 10"
```js
assert(testGreaterThan(99) === 'Over 10');
2018-10-04 13:37:37 +00:00
```
2020-11-27 18:02:05 +00:00
`testGreaterThan(100)` should return "Over 10"
2018-10-04 13:37:37 +00:00
2020-11-27 18:02:05 +00:00
```js
assert(testGreaterThan(100) === 'Over 10');
```
2018-10-04 13:37:37 +00:00
2020-11-27 18:02:05 +00:00
`testGreaterThan(101)` should return "Over 100"
```js
assert(testGreaterThan(101) === 'Over 100');
```
`testGreaterThan(150)` should return "Over 100"
```js
assert(testGreaterThan(150) === 'Over 100');
```
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 testGreaterThan(val) {
if (val) { // Change this line
return "Over 100";
}
2018-10-08 00:01:53 +00:00
2018-10-04 13:37:37 +00:00
if (val) { // Change this line
return "Over 10";
}
return "10 or Under";
}
testGreaterThan(10);
```
2020-11-27 18:02:05 +00:00
# --solutions--
2018-10-04 13:37:37 +00:00
```js
function testGreaterThan(val) {
if (val > 100) { // Change this line
return "Over 100";
}
if (val > 10) { // Change this line
return "Over 10";
}
return "10 or Under";
}
```