2018-10-12 15:37:13 -04:00
---
title: Comparison with the Strict Inequality Operator
---
2019-07-24 00:59:27 -07:00
# Comparison with the Strict Inequality Operator
2018-10-12 15:37:13 -04:00
2019-07-24 00:59:27 -07:00
---
## Problem Explanation
2018-10-12 15:37:13 -04: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`._
2019-07-24 00:59:27 -07:00
---
## Hints
### Hint 1
2018-10-12 15:37:13 -04:00
The strict inequality operator (`!==` ) will return `true` if the first value is not equal to the second one taking value type into consideration.
2019-07-24 00:59:27 -07:00
---
## Solutions
< details > < summary > Solution 1 (Click to Show/Hide)< / summary >
2018-10-12 15:37:13 -04:00
```javascript
function testStrictNotEqual(val) {
if (val !== 17) {
return "Not equal";
}
return "Equal";
}
// Change this value to test
testStrictNotEqual(10);
```
2019-07-24 00:59:27 -07:00
#### Code Explanation
2018-10-12 15:37:13 -04:00
The function first evaluates `if` the condition `(val !== 17)` evaluates to `true` considering both value and value type. If it does, it returns the statement between the curly braces ("Not equal"). If it doesn't, it returns the next `return` statement outside them ("Equal").
2019-07-24 00:59:27 -07:00
#### Relevant Links
2018-10-12 15:37:13 -04:00
- ["Non-identity / strict inequality (!==)" - *MDN JavaScript reference* ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Non-identity_strict_inequality_(! ))
2019-07-24 00:59:27 -07:00
< / details >