Dont Understand this how this equality operator works

Tell us what’s happening:
According to my understanding, the === operator compares both types and values at the same time. I just dont understand that when the exercise was showing a comparison of 3 === “3”, it would return as false. But the real answer is now saying that when a === b AKA 10 === “10”, it is now considered Equal or true in this case. This whole exercise is straight up messing with my brain right now.
Someone please explain to me whats going on. Thanks!

Your code so far

// Setup
function compareEquality(a, b) {
if (a === b) { // Change this line
  return "Equal";
return "Not Equal";

// Change this value to test
compareEquality(10, "10");

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36.

Challenge: Practice comparing different values

Link to the challenge:

Hello, Rosh.

I think I see where your confusion is. I suggest you add this to the bottom of your script, and see the output:


To clarify, there lesson means exactly what it says:

== performs type conversion before testing for equality
=== strictly tests for equality

The real answer is not saying 10 === "10". Even if you set a=10, and b="10". The challenge is getting you to correct the function compareEquality so that it will only return Equal if a === b.

As I said, log the output of the function to the console. It will clear everything up.

1 Like