OneBite.Dev - Coding blog in a bite size

check if two variable not equal in Javascript

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

  if (var1 !== var2) {
    // do something
  }

This code checks if two variables, named “var1” and “var2”, are not equal. The ”!” denotes not equal, so “if var1 is not equal to var2” is asking, “if var1 is different from var2”. The code will run whatever is between the curly brackets if var1 and var2 are not equal. If they are equal, the code between the brackets will not run. This code uses the “if” statement to execute the code only if the condition is true. The code can be modified to include more conditions or operations if needed.

javascript