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
2021-01-13 02:31:00 +00:00
dashedName: comparison-with-the-greater-than-operator
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
2021-03-03 00:12:12 +00:00
5 > 3
7 > '3'
2 > 3
'1' > 9
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` , `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 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--
2021-03-03 00:12:12 +00:00
`testGreaterThan(0)` should return the string `10 or Under`
2020-11-27 18:02:05 +00:00
```js
assert(testGreaterThan(0) === '10 or Under');
```
2021-03-03 00:12:12 +00:00
`testGreaterThan(10)` should return the string `10 or Under`
2020-11-27 18:02:05 +00:00
```js
assert(testGreaterThan(10) === '10 or Under');
```
2021-03-03 00:12:12 +00:00
`testGreaterThan(11)` should return the string `Over 10`
2020-11-27 18:02:05 +00:00
```js
assert(testGreaterThan(11) === 'Over 10');
```
2021-03-03 00:12:12 +00:00
`testGreaterThan(99)` should return the string `Over 10`
2020-11-27 18:02:05 +00:00
```js
assert(testGreaterThan(99) === 'Over 10');
2018-10-04 13:37:37 +00:00
```
2021-03-03 00:12:12 +00:00
`testGreaterThan(100)` should return the string `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
2021-03-03 00:12:12 +00:00
`testGreaterThan(101)` should return the string `Over 100`
2020-11-27 18:02:05 +00:00
```js
assert(testGreaterThan(101) === 'Over 100');
```
2021-03-03 00:12:12 +00:00
`testGreaterThan(150)` should return the string `Over 100`
2020-11-27 18:02:05 +00:00
```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";
}
```