Comparison with the Strict Inequality Operator (revived)

Comparison with the Strict Inequality Operator (revived)
0

#1

Tell us what’s happening:

Hi! This seemed simple enough, however I cannot get the first test to pass. Could anyone Please help. I’ve exhausted Read and Search, as all the information I found says to do as I’ve done.

Your code so far

// Setup
function testStrictNotEqual(val) {
  // Only Change Code Below this Line
  
  if (val !== 17); { 

  // Only Change Code Above this Line

    return "Not Equal";
  }
  return "Equal";
}

// Change this value to test
testStrictNotEqual(10);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36.

Link to the challenge:


#2

Hi KayCodes,

  1. Looks like you have extra ‘;’ after if (val !== 17)
  2. When you have more than 1 ‘if’ statement you should use ‘else’

The solution should look like:

function testNotEqual(val) {
  if (val != 99) { 
    return "Not Equal";
  } else {
    return "Equal";   
  }
}
testNotEqual(12);

Please test it and let me know if you run into troubles.


#3

Thank you! I tried the next challenge without the " ; " and that seemed to be the problem! I passed without the “else” but will keep that in mind for the future. Its always the little things with coding! Thanks a lot.


#4

This solution does not need an else, because there is only one if statement and if the “if condition” is false, the return at the end of the function will take care of returning the correct string.