freeCodeCamp/guide/english/certifications/javascript-algorithms-and-d.../basic-javascript/comparison-with-the-inequal.../index.md

474 B

title
Comparison with the Inequality Operator

Comparison with the Inequality Operator

  • != (Inequality) is a logical operator that returns true case the value on the left is different from the one on the right.
  • The inequality operator considers 7 and "7" to be the same because it doesn't compare the type of the variable.

Basic Solution

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