2018-10-04 14:37:37 +01:00
---
id: 56533eb9ac21ba0edf2244d4
title: Comparison with the Greater Than Operator
challengeType: 1
2019-02-14 12:24:02 -05:00
videoUrl: 'https://scrimba.com/c/cp6GbH4'
2019-07-31 11:32:23 -07:00
forumTopicId: 16786
2021-01-13 03:31:00 +01:00
dashedName: comparison-with-the-greater-than-operator
2018-10-04 14:37:37 +01:00
---
2020-11-27 19:02:05 +01: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 14:37:37 +01:00
Like the equality operator, greater than operator will convert data types of values while comparing.
2020-11-27 19:02:05 +01:00
**Examples**
2019-05-17 06:20:30 -07:00
```js
5 > 3 // true
7 > '3' // true
2 > 3 // false
'1' > 9 // false
```
2020-11-27 19:02:05 +01:00
# --instructions--
2018-10-04 14:37:37 +01:00
2019-10-27 15:45:37 -01:00
Add the greater than operator to the indicated lines so that the return statements make sense.
2018-10-04 14:37:37 +01:00
2020-11-27 19:02:05 +01: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 14:37:37 +01:00
```
2020-11-27 19:02:05 +01:00
`testGreaterThan(100)` should return "Over 10"
2018-10-04 14:37:37 +01:00
2020-11-27 19:02:05 +01:00
```js
assert(testGreaterThan(100) === 'Over 10');
```
2018-10-04 14:37:37 +01:00
2020-11-27 19:02:05 +01: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 14:37:37 +01:00
```js
function testGreaterThan(val) {
if (val) { // Change this line
return "Over 100";
}
2018-10-08 01:01:53 +01:00
2018-10-04 14:37:37 +01:00
if (val) { // Change this line
return "Over 10";
}
return "10 or Under";
}
testGreaterThan(10);
```
2020-11-27 19:02:05 +01:00
# --solutions--
2018-10-04 14:37:37 +01: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";
}
```