2018-10-10 18:03:03 -04:00
---
id: 56533eb9ac21ba0edf2244d2
2021-02-06 04:42:36 +00:00
title: Comparison with the 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/cdBm9Sr'
forumTopicId: 16787
2021-01-13 03:31:00 +01:00
dashedName: comparison-with-the-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 inequality operator (`!=` ) is the opposite of the equality operator. It means "Not Equal" and returns `false` where equality would return `true` and *vice versa* . Like the equality operator, the inequality operator will convert data types of values while comparing.
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
1 != 2 // true
1 != "1" // false
1 != '1' // false
1 != true // false
0 != false // false
```
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 inequality operator `!=` in the `if` statement so that the function will return "Not Equal" when `val` is not equivalent to `99`
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
`testNotEqual(99)` should return "Equal"
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(testNotEqual(99) === 'Equal');
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
`testNotEqual("99")` should return "Equal"
2018-10-10 18:03:03 -04:00
```js
2020-12-16 00:37:30 -07:00
assert(testNotEqual('99') === 'Equal');
2018-10-10 18:03:03 -04:00
```
2021-02-06 04:42:36 +00:00
`testNotEqual(12)` should return "Not Equal"
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(testNotEqual(12) === 'Not Equal');
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
`testNotEqual("12")` should return "Not Equal"
2020-12-16 00:37:30 -07:00
```js
assert(testNotEqual('12') === 'Not Equal');
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
`testNotEqual("bob")` should return "Not Equal"
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(testNotEqual('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(/(?!!==)!=/));
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 testNotEqual(val) {
if (val) { // Change this line
return "Not Equal";
}
return "Equal";
}
testNotEqual(10);
```
2020-12-16 00:37:30 -07:00
# --solutions--
2021-01-13 03:31:00 +01:00
```js
function testNotEqual(val) {
if (val != 99) {
return "Not Equal";
}
return "Equal";
}
```