2018-09-30 22:01:58 +00:00
---
id: 56533eb9ac21ba0edf2244d2
title: Comparison with the Inequality Operator
challengeType: 1
2019-02-14 17:24:02 +00:00
videoUrl: 'https://scrimba.com/c/cdBm9Sr'
2019-07-31 18:32:23 +00:00
forumTopicId: 16787
2021-01-13 02:31:00 +00:00
dashedName: comparison-with-the-inequality-operator
2018-09-30 22:01:58 +00:00
---
2020-11-27 18:02:05 +00:00
# --description--
2021-03-03 00:12:12 +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-11-27 18:02:05 +00:00
**Examples**
2019-05-17 13:20:30 +00:00
```js
2021-03-03 00:12:12 +00:00
1 != 2
1 != "1"
1 != '1'
1 != true
0 != false
2019-05-17 13:20:30 +00:00
```
2021-03-03 00:12:12 +00:00
In order, these expressions would evaluate to `true` , `false` , `false` , `false` , and `false` .
2020-11-27 18:02:05 +00:00
# --instructions--
2021-03-03 00:12:12 +00:00
Add the inequality operator `!=` in the `if` statement so that the function will return the string `Not Equal` when `val` is not equivalent to `99`
2020-11-27 18:02:05 +00:00
# --hints--
2021-03-03 00:12:12 +00:00
`testNotEqual(99)` should return the string `Equal`
2020-11-27 18:02:05 +00:00
```js
assert(testNotEqual(99) === 'Equal');
```
2021-03-03 00:12:12 +00:00
`testNotEqual("99")` should return the string `Equal`
2020-11-27 18:02:05 +00:00
```js
assert(testNotEqual('99') === 'Equal');
```
2021-03-03 00:12:12 +00:00
`testNotEqual(12)` should return the string `Not Equal`
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
assert(testNotEqual(12) === 'Not Equal');
2018-09-30 22:01:58 +00:00
```
2021-03-03 00:12:12 +00:00
`testNotEqual("12")` should return the string `Not Equal`
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
assert(testNotEqual('12') === 'Not Equal');
```
2018-09-30 22:01:58 +00:00
2021-03-03 00:12:12 +00:00
`testNotEqual("bob")` should return the string `Not Equal`
2020-11-27 18:02:05 +00:00
```js
assert(testNotEqual('bob') === 'Not Equal');
```
You should use the `!=` operator
```js
assert(code.match(/(?!!==)!=/));
```
# --seed--
## --seed-contents--
2018-09-30 22:01:58 +00:00
```js
// Setup
function testNotEqual(val) {
if (val) { // Change this line
return "Not Equal";
}
return "Equal";
}
testNotEqual(10);
```
2020-11-27 18:02:05 +00:00
# --solutions--
2018-09-30 22:01:58 +00:00
```js
function testNotEqual(val) {
if (val != 99) {
return "Not Equal";
}
return "Equal";
}
```