Practice comparing different values

Tell us what’s happening:

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 (Linux; Android 7.0; CTAB-1044 Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/practice-comparing-different-values/

They want you to understand the difference between equal and strictly equal. The second one makes sure that they are the same type, the first one doesn’t care. So:

1 == "1"; // true
1 === "1"; // false

The first one passes because JS converts them into the same type first and then compares them.

The second one fails because JS doesn’t convert anything, it sees that one is a string and the other is a number and it doesn’t bother going forward. If the second one had two values of the same type, then it would check them.