--- id: 56533eb9ac21ba0edf2244d3 challengeType: 1 videoUrl: 'https://scrimba.com/c/cKekkUy' forumTopicId: 16791 title: 严格不等运算符 --- ## Description
严格不相等运算符(!==)与全等运算符是相反的。这意味着严格不相等并返回false的地方,用严格相等运算符会返回true反之亦然。严格不相等运算符不会转换值的数据类型。 示例 ```js 3 !== 3 // false 3 !== '3' // true 4 !== 3 // true ```
## Instructions
if语句中,添加严格不相等运算符!==,这样如果val17严格不相等的时候,函数会返回 "Not Equal"。
## Tests
```yml tests: - text: testStrictNotEqual(17)应该返回 "Equal"。 testString: assert(testStrictNotEqual(17) === "Equal"); - text: testStrictNotEqual("17")应该返回 "Not Equal"。 testString: assert(testStrictNotEqual("17") === "Not Equal"); - text: testStrictNotEqual(12)应该返回 "Not Equal"。 testString: assert(testStrictNotEqual(12) === "Not Equal"); - text: testStrictNotEqual("bob")应该返回 "Not Equal"。 testString: assert(testStrictNotEqual("bob") === "Not Equal"); - text: 应该使用 !== 运算符。 testString: assert(code.match(/(val\s*!==\s*\d+)|(\d+\s*!==\s*val)/g).length > 0); ```
## Challenge Seed
```js // Setup function testStrictNotEqual(val) { if (val) { // Change this line return "Not Equal"; } return "Equal"; } // Change this value to test testStrictNotEqual(10); ```
## Solution
```js function testStrictNotEqual(val) { if (val !== 17) { return "Not Equal"; } return "Equal"; } ```