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:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/practice-comparing-different-values