2018-09-30 23:01:58 +01:00
---
id: 56533eb9ac21ba0edf2244d2
title: Comparison with the Inequality Operator
challengeType: 1
2019-02-14 12:24:02 -05:00
videoUrl: 'https://scrimba.com/c/cdBm9Sr'
2018-09-30 23:01:58 +01:00
---
## Description
< section id = 'description' >
The inequality operator (< code > !=< / code > ) is the opposite of the equality operator. It means "Not Equal" and returns < code > false< / code > where equality would return < code > true< / code > and < em > vice versa< / em > . Like the equality operator, the inequality operator will convert data types of values while comparing.
< strong > Examples< / strong >
< blockquote > 1 != 2 // true< br > 1 != "1" // false< br > 1 != '1' // false< br > 1 != true // false< br > 0 != false // false< / blockquote >
< / section >
## Instructions
< section id = 'instructions' >
Add the inequality operator < code > !=< / code > in the < code > if< / code > statement so that the function will return "Not Equal" when < code > val< / code > is not equivalent to < code > 99< / code >
< / section >
## Tests
< section id = 'tests' >
```yml
2018-10-04 14:37:37 +01:00
tests:
- text: < code > testNotEqual(99)</ code > should return "Equal"
2018-10-20 21:02:47 +03:00
testString: assert(testNotEqual(99) === "Equal", '< code > testNotEqual(99)< / code > should return "Equal"');
2018-10-04 14:37:37 +01:00
- text: < code > testNotEqual("99")</ code > should return "Equal"
2018-10-20 21:02:47 +03:00
testString: assert(testNotEqual("99") === "Equal", '< code > testNotEqual("99")< / code > should return "Equal"');
2018-10-04 14:37:37 +01:00
- text: < code > testNotEqual(12)</ code > should return "Not Equal"
2018-10-20 21:02:47 +03:00
testString: assert(testNotEqual(12) === "Not Equal", '< code > testNotEqual(12)< / code > should return "Not Equal"');
2018-10-04 14:37:37 +01:00
- text: < code > testNotEqual("12")</ code > should return "Not Equal"
2018-10-20 21:02:47 +03:00
testString: assert(testNotEqual("12") === "Not Equal", '< code > testNotEqual("12")< / code > should return "Not Equal"');
2018-10-04 14:37:37 +01:00
- text: < code > testNotEqual("bob")</ code > should return "Not Equal"
2018-10-20 21:02:47 +03:00
testString: assert(testNotEqual("bob") === "Not Equal", '< code > testNotEqual("bob")< / code > should return "Not Equal"');
2018-10-04 14:37:37 +01:00
- text: You should use the < code > !=</ code > operator
2018-10-20 21:02:47 +03:00
testString: assert(code.match(/(?!!==)!=/), 'You should use the < code > !=< / code > operator');
2018-09-30 23:01:58 +01:00
```
< / section >
## Challenge Seed
< section id = 'challengeSeed' >
< div id = 'js-seed' >
```js
// Setup
function testNotEqual(val) {
if (val) { // Change this line
return "Not Equal";
}
return "Equal";
}
// Change this value to test
testNotEqual(10);
```
< / div >
< / section >
## Solution
< section id = 'solution' >
```js
function testNotEqual(val) {
if (val != 99) {
return "Not Equal";
}
return "Equal";
}
```
< / section >