Inequality Operator (!=)

By: Dusty Arlia
Published on September 27, 2012
Last Updated on Thursday, July 16, 2015 at 7:43 PM
Total Updates: 5

The inequality operator tests to see if two values are not equal. If they are not equal, then the condition is true.

Here is the structure of a conditional statement:

(/*condition*/) {
/*
If the condition is true then
the code in between these two
curly braces will run. If the
condition is false, then this
code will be skipped over.
*/
}

Here is an example of the inequality operator in action:

(numberOfEggs != 12) {
alert('Not a dozen of eggs');
} 

If the variable numberOfEggs does not equal the number 12, then the condition is true. If the condition is true, the string 'Not a dozen eggs' gets displayed in an alert box. If the condition is false, then the code in between the curly braces is skipped over and the program would continue to run.

Comments:

Ad: