OneBite.Dev - Coding blog in a bite size

check if two variable is not equal in Javascript

Code snippet on how to check if two variable is not equal in Javascript

  if (x !== y) { 
    console.log("x and y are not equal");
  }

This code checks if two variables, x and y, are not equal. It starts with an if statement, which checks if the statement inside the parentheses is true. The statement inside the parentheses is two variables, x and y, joined by an exclamation mark and an equal sign. This combination creates an inequality statement, which checks that the two variables are not equal. If the statement is true, the code inside the curly brackets will run. In this case, it prints “x and y are not equal”. If the statement is false, the code inside the brackets will not run and the program will move on to the next line of code.

javascript