Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

111 lines
2.1 KiB
Markdown

---
id: 56533eb9ac21ba0edf2244d4
title: Comparison with the Greater Than Operator
challengeType: 1
forumTopicId: 16786
dashedName: comparison-with-the-greater-than-operator
---
# --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`.
Like the equality operator, the greater than operator will convert data types of values while comparing.
**Examples**
```js
5 > 3 // true
7 > '3' // true
2 > 3 // false
'1' > 9 // false
```
# --instructions--
Add the greater than operator to the indicated lines so that the return statements make sense.
# --hints--
`testGreaterThan(0)` should return the string `10 or Under`
```js
assert(testGreaterThan(0) === '10 or Under');
```
`testGreaterThan(10)` should return the string `10 or Under`
```js
assert(testGreaterThan(10) === '10 or Under');
```
`testGreaterThan(11)` should return the string `Over 10`
```js
assert(testGreaterThan(11) === 'Over 10');
```
`testGreaterThan(99)` should return the string `Over 10`
```js
assert(testGreaterThan(99) === 'Over 10');
```
`testGreaterThan(100)` should return the string `Over 10`
```js
assert(testGreaterThan(100) === 'Over 10');
```
`testGreaterThan(101)` should return the string `Over 100`
```js
assert(testGreaterThan(101) === 'Over 100');
```
`testGreaterThan(150)` should return the string `Over 100`
```js
assert(testGreaterThan(150) === 'Over 100');
```
You should use the `>` operator at least twice
```js
assert(__helpers.removeJSComments(code).match(/val\s*>\s*('|")*\d+('|")*/g).length > 1);
```
# --seed--
## --seed-contents--
```js
function testGreaterThan(val) {
if (val) { // Change this line
return "Over 100";
}
if (val) { // Change this line
return "Over 10";
}
return "10 or Under";
}
testGreaterThan(10);
```
# --solutions--
```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";
}
```