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
83 lines
1.7 KiB
Markdown
83 lines
1.7 KiB
Markdown
---
|
|
id: 56533eb9ac21ba0edf2244d3
|
|
title: Comparison with the Strict Inequality Operator
|
|
challengeType: 1
|
|
forumTopicId: 16791
|
|
dashedName: comparison-with-the-strict-inequality-operator
|
|
---
|
|
|
|
# --description--
|
|
|
|
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*. The strict inequality operator will not convert data types.
|
|
|
|
**Examples**
|
|
|
|
```js
|
|
3 !== 3 // false
|
|
3 !== '3' // true
|
|
4 !== 3 // true
|
|
```
|
|
|
|
# --instructions--
|
|
|
|
Add the strict inequality operator to the `if` statement so the function will return the string `Not Equal` when `val` is not strictly equal to `17`
|
|
|
|
# --hints--
|
|
|
|
`testStrictNotEqual(17)` should return the string `Equal`
|
|
|
|
```js
|
|
assert(testStrictNotEqual(17) === 'Equal');
|
|
```
|
|
|
|
`testStrictNotEqual("17")` should return the string `Not Equal`
|
|
|
|
```js
|
|
assert(testStrictNotEqual('17') === 'Not Equal');
|
|
```
|
|
|
|
`testStrictNotEqual(12)` should return the string `Not Equal`
|
|
|
|
```js
|
|
assert(testStrictNotEqual(12) === 'Not Equal');
|
|
```
|
|
|
|
`testStrictNotEqual("bob")` should return the string `Not Equal`
|
|
|
|
```js
|
|
assert(testStrictNotEqual('bob') === 'Not Equal');
|
|
```
|
|
|
|
You should use the `!==` operator
|
|
|
|
```js
|
|
assert(__helpers.removeJSComments(code).match(/(val\s*!==\s*\d+)|(\d+\s*!==\s*val)/g).length > 0);
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```js
|
|
// Setup
|
|
function testStrictNotEqual(val) {
|
|
if (val) { // Change this line
|
|
return "Not Equal";
|
|
}
|
|
return "Equal";
|
|
}
|
|
|
|
testStrictNotEqual(10);
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```js
|
|
function testStrictNotEqual(val) {
|
|
if (val !== 17) {
|
|
return "Not Equal";
|
|
}
|
|
return "Equal";
|
|
}
|
|
```
|