2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
id: 56533eb9ac21ba0edf2244d2
|
|
|
|
|
title: Comparison with the Inequality Operator
|
|
|
|
|
challengeType: 1
|
|
|
|
|
videoUrl: ''
|
|
|
|
|
localeTitle: 与不等式算子的比较
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
<section id="description">不等运算符( <code>!=</code> )与等于运算符相反。它意味着“不等于”并返回<code>false</code> ,其中相等性将返回<code>true</code> , <em>反之亦然</em> 。与等式运算符一样,不等式运算符将在比较时转换数据类型的值。 <strong>例子</strong> <blockquote> 1!= 2 //是的<br> 1!=“1”//假<br> 1!='1'//假<br> 1!= true // false <br> 0!= false // false </blockquote></section>
|
|
|
|
|
|
|
|
|
|
## Instructions
|
|
|
|
|
<section id="instructions">在<code>if</code>语句中添加不等式运算符<code>!=</code> ,以便当<code>val</code>不等于<code>99</code>时函数将返回“Not Equal” </section>
|
|
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
tests:
|
|
|
|
|
- text: <code>testNotEqual(99)</code>应返回“Equal”
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert(testNotEqual(99) === "Equal");
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>testNotEqual("99")</code>应该返回“Equal”
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert(testNotEqual("99") === "Equal");
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>testNotEqual(12)</code>应该返回“Not Equal”
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert(testNotEqual(12) === "Not Equal");
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>testNotEqual("12")</code>应该返回“Not Equal”
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert(testNotEqual("12") === "Not Equal");
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>testNotEqual("bob")</code>应返回“Not Equal”
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert(testNotEqual("bob") === "Not Equal");
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: 你应该使用<code>!=</code>运算符
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert(code.match(/(?!!==)!=/));
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
|
|
<div id='js-seed'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
// Setup
|
|
|
|
|
function testNotEqual(val) {
|
|
|
|
|
if (val) { // Change this line
|
|
|
|
|
return "Not Equal";
|
|
|
|
|
}
|
|
|
|
|
return "Equal";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Change this value to test
|
|
|
|
|
testNotEqual(10);
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|
|
|
|
|
</section>
|