2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
id: 56533eb9ac21ba0edf2244d4
|
|
|
|
title: Comparison with the Greater Than Operator
|
|
|
|
challengeType: 1
|
|
|
|
videoUrl: ''
|
|
|
|
localeTitle: 与大于运营商的比较
|
|
|
|
---
|
|
|
|
|
|
|
|
## Description
|
|
|
|
<section id="description">大于运算符( <code>></code> )比较两个数字的值。如果左边的数字大于右边的数字,则返回<code>true</code> 。否则,它返回<code>false</code> 。与等于运算符一样,大于运算符将在比较时转换数据类型的值。 <strong>例子</strong> <blockquote> 5> 3 //是的<br> 7>'3'//是的<br> 2> 3 //假<br> '1'> 9 //假</blockquote></section>
|
|
|
|
|
|
|
|
## Instructions
|
|
|
|
<section id="instructions">将<code>greater than</code>运算符添加到指示的行,以便返回语句有意义。 </section>
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
```yml
|
|
|
|
tests:
|
|
|
|
- text: <code>testGreaterThan(0)</code>应返回“10或Under”
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert(testGreaterThan(0) === "10 or Under");
|
2018-10-10 18:03:03 -04:00
|
|
|
- text: <code>testGreaterThan(10)</code>应返回“10或Under”
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert(testGreaterThan(10) === "10 or Under");
|
2018-10-10 18:03:03 -04:00
|
|
|
- text: <code>testGreaterThan(11)</code>应该返回“Over 10”
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert(testGreaterThan(11) === "Over 10");
|
2018-10-10 18:03:03 -04:00
|
|
|
- text: <code>testGreaterThan(99)</code>应该返回“Over 10”
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert(testGreaterThan(99) === "Over 10");
|
2018-10-10 18:03:03 -04:00
|
|
|
- text: <code>testGreaterThan(100)</code>应该返回“Over 10”
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert(testGreaterThan(100) === "Over 10");
|
2018-10-10 18:03:03 -04:00
|
|
|
- text: <code>testGreaterThan(101)</code>应返回“超过100”
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert(testGreaterThan(101) === "Over 100");
|
2018-10-10 18:03:03 -04:00
|
|
|
- text: <code>testGreaterThan(150)</code>应该返回“超过100”
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert(testGreaterThan(150) === "Over 100");
|
2018-10-10 18:03:03 -04:00
|
|
|
- text: 您应该至少使用<code>></code>运算符两次
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert(code.match(/val\s*>\s*('|")*\d+('|")*/g).length > 1);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
<div id='js-seed'>
|
|
|
|
|
|
|
|
```js
|
|
|
|
function testGreaterThan(val) {
|
|
|
|
if (val) { // Change this line
|
|
|
|
return "Over 100";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (val) { // Change this line
|
|
|
|
return "Over 10";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "10 or Under";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Change this value to test
|
|
|
|
testGreaterThan(10);
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
|
|
```js
|
|
|
|
// solution required
|
|
|
|
```
|
|
|
|
</section>
|