Comparison with the Strict Equality Operators

Comparison with the Strict Equality Operators
0

#1

Tell us what’s happening:

Your code so far

// Setup
function testStrict(myVal) {
  if (myVal === 7) if (myVal == "7") { // Change this line
    return "Equal";
  }
  return "Not Equal";
}

// Change this value to test
testStrict(7);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; CrOS x86_64 10032.86.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.140 Safari/537.36.

Link to the challenge:


#2

What is wrong with this?


#3

You might want to back up a few challenges and make sure you understand how to write an if statement, because the following is not valid syntax.

  if (myVal === 7) if (myVal == "7") { // Change this line

EDIT: Let me correct myself. It is valid syntax, because it does not error out, but it is the equivalent of writing the following:

function testStrict(myVal) {
  if (myVal === 7) {
    if (myVal == "7") { // Change this line
      return "Equal";
    }
  }
  return "Not Equal";
}

You only need one if statement to solve this challenge.