# freeCodeCamp Challenge Guide: Comparison with the Strict Equality Operator

**URL:** <https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-comparison-with-the-strict-equality-operator/16790>\
**Category:** freeCodeCamp Contributors\
**Tags:** guide\
**Created:** [July 3, 2016, 3:45am UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-comparison-with-the-strict-equality-operator/16790 "2016-07-03T03:45:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![camperbot](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/camperbot/32/18364_2.png) [@camperbot](https://forum.freecodecamp.org/u/camperbot)\
**Post date:** [July 3, 2016, 3:45am UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-comparison-with-the-strict-equality-operator/16790/1 "2016-07-03T03:45:11Z")

</div>

# [Comparison with the strict equality operator](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-equality-operator)

* * *

## Problem Explanation

· _Use the strict equality operator in the `if` statement so the function will return “Equal” when `val` is strictly equal to `7`._

* * *

## Hints

### Hint 1

Remember from last exercise that _equality is different from assignment (`=`), which assigns the value at the right of the operator to a variable in the left._[1](#cite1)

### Hint 2

_Unlike the equality operator, which attempts to convert both values being compared to a common type, the strict equality operator does not perform a type conversion._[2](#cite2)

* * *

## Solutions

> **Solution 1 (Click to Show/Hide)**
>
> ```javascript
> // Setup
> function testStrict(val) {
> if (val === 7) {
> // Change this line
> return "Equal";
> }
> return "Not equal";
> }
> 
> // Change this value to test
> testStrict(10);
> 
> ```
> 
> #### Code Explanation
> 
> The function first evaluates `if` the condition `(val === 7)` evaluates to `true`. If it does, it returns the statement between the curly braces (“Equal”). If it doesn’t, it returns the next `return` statement outside them (“Not equal”).
> 
> #### Relevant Links
> 
> 1. [“Basic JavaScript: Comparison with the Equality Operator”, fCC lesson at _JavaScript Algorithms And Data Structures Certification_](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-equality-operator)
> 
> 2. [“Basic JavaScript: Comparison with the Strict Equality Operator”, fCC lesson at _JavaScript Algorithms And Data Structures Certification_](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-equality-operator)
> 
> #### Relevant Links
> 
> - [“if…else” - _MDN JavaScript reference_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else)
> 
> - [Kondov, Alexander. “Understanding JS: Coercion”. _Hackernoon_](https://hackernoon.com/understanding-js-coercion-ff5684475bfc) Accessed 15 Sep. 2018
> 
> - [“Comparison operators” - _MDN JavaScript reference_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators)

---

<div class="post-metadata">

**Author:** ![anon52159105](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@anon52159105](https://forum.freecodecamp.org/u/anon52159105)\
**Post date:** [August 6, 2017, 11:27pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-comparison-with-the-strict-equality-operator/16790/2 "2017-08-06T23:27:58Z")

</div>



---

<div class="post-metadata">

**Author:** ![camperbot](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/camperbot/32/18364_2.png) [@camperbot](https://forum.freecodecamp.org/u/camperbot)\
**Post date:** [August 10, 2019, 1:17am UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-comparison-with-the-strict-equality-operator/16790/3 "2019-08-10T01:17:38Z")

</div>



---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 7, 2025, 12:00pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-comparison-with-the-strict-equality-operator/16790/4 "2025-01-07T12:00:52Z")

</div>


