Why is it right?

Tell us what’s happening:
Describe your issue in detail here.

Checked why this is correct by condition?

10 != 99 this is true so “Not Equal”

  **Your code so far**

// Setup
function testNotEqual(val) {
if (val != 99) { // Change this line
  return "Not Equal";
}
return "Equal";
}

testNotEqual(10);
  **Your browser information:**

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36.

Challenge: Comparison with the Inequality Operator

Link to the challenge:

Can you elaborate your question?
I don’t know why you think this shouldn’t be right.

2 Likes

testNotEqual(99) должен вернуть строку Equal but it returns during processing “Not Equal” by condition if

The things on the left are the test cases, that call the function you have written on the right. They do not care what you have written outside of the function.

If you want to see the output of what you have written, you need to put it int console.log(testNotEqual(99)).
This will create an output on the right, in the lower part.

2 Likes

I do not really understand you!

The condition is written incorrectly if, when executing the function, it turns out Not Equal

Each test listed on the lower left side of your screen calls the function with different arguments.

// Setup
function testNotEqual(val) {
if (val != 99) { // Change this line
  return "Not Equal";
}
return "Equal";
}

testNotEqual(99); // This is what the first test does
testNotEqual("99"); // This is what the second test does
testNotEqual(12); // This is what the third test does
testNotEqual("12"); // This is what the fourth test does
testNotEqual("bob"); // This is what the fifth test does

The test suite makes those 5 function calls on its own.

1 Like

And I think I understood everything, but I wrote the condition (val! = 99)
not val! = 12
or something different! Thank you!

Yes, you wrote val != 99, which is why you get the correct result. If you had written val != 12, then the function would have the wrong result.

What do you see if you actually run the following code?

// Setup
function testNotEqual(val) {
  console.log("val is: " + val);
  console.log("val != 99 is:" + (val != 99));
  // ---------------------------------
  if (val != 99) { // Change this line
    return "Not Equal";
  }
  return "Equal";
}

testNotEqual(99); // This is what the first test does
testNotEqual("99"); // This is what the second test does
testNotEqual(12); // This is what the third test does
testNotEqual("12"); // This is what the fourth test does
testNotEqual("bob"); // This is what the fifth test does
1 Like

Thanks I got it! Just a little confused(

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.