2018-10-10 18:03:03 -04:00
---
id: 56533eb9ac21ba0edf2244d3
2021-02-06 04:42:36 +00:00
title: Comparison with the Strict Inequality Operator
2018-10-10 18:03:03 -04:00
challengeType: 1
2020-04-29 18:29:13 +08:00
videoUrl: 'https://scrimba.com/c/cKekkUy'
forumTopicId: 16791
2021-01-13 03:31:00 +01:00
dashedName: comparison-with-the-strict-inequality-operator
2018-10-10 18:03:03 -04:00
---
2020-12-16 00:37:30 -07:00
# --description--
2021-02-06 04:42:36 +00:00
The strict inequality operator (`!==` ) is the logical opposite of the strict equality operator. It means "Strictly Not Equal" and returns `false` where strict equality would return `true` and *vice versa* . Strict inequality will not convert data types.
2020-12-16 00:37:30 -07:00
2021-02-06 04:42:36 +00:00
**Examples**
2020-04-29 18:29:13 +08:00
```js
3 !== 3 // false
3 !== '3' // true
4 !== 3 // true
```
2020-12-16 00:37:30 -07:00
# --instructions--
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
Add the strict inequality operator to the `if` statement so the function will return "Not Equal" when `val` is not strictly equal to `17`
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
# --hints--
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
`testStrictNotEqual(17)` should return "Equal"
2018-10-10 18:03:03 -04:00
```js
2020-12-16 00:37:30 -07:00
assert(testStrictNotEqual(17) === 'Equal');
2018-10-10 18:03:03 -04:00
```
2021-02-06 04:42:36 +00:00
`testStrictNotEqual("17")` should return "Not Equal"
2020-12-16 00:37:30 -07:00
```js
assert(testStrictNotEqual('17') === 'Not Equal');
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
`testStrictNotEqual(12)` should return "Not Equal"
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(testStrictNotEqual(12) === 'Not Equal');
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
`testStrictNotEqual("bob")` should return "Not Equal"
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(testStrictNotEqual('bob') === 'Not Equal');
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
You should use the `!==` operator
2020-04-29 18:29:13 +08:00
2018-10-10 18:03:03 -04:00
```js
2020-12-16 00:37:30 -07:00
assert(code.match(/(val\s*!==\s*\d+)|(\d+\s*!==\s*val)/g).length > 0);
2018-10-10 18:03:03 -04:00
```
2020-04-29 18:29:13 +08:00
2021-01-13 03:31:00 +01:00
# --seed--
## --seed-contents--
```js
// Setup
function testStrictNotEqual(val) {
if (val) { // Change this line
return "Not Equal";
}
return "Equal";
}
testStrictNotEqual(10);
```
2020-12-16 00:37:30 -07:00
# --solutions--
2021-01-13 03:31:00 +01:00
```js
function testStrictNotEqual(val) {
if (val !== 17) {
return "Not Equal";
}
return "Equal";
}
```