We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Comparison Operators

You should already be familiar with these inequality operators, and they work as you would expect in JavaScript:

5 < 6; // evaluates to true
5 > 6; // evaluates to false
5 >= 6; // evaluates to false
5 <= 6; // evaluates to true

The equality operators, however, are a bit... strange. To compare two values to see if they are exactly the same, use the strict equality (===) and strict inequality (!==) operators:

5 === 6; // evaluates to false
5 !== 6; // evaluates to true

The "normal" equality (==) and inequality (!=) operators are a bit more... flexible:

5 == 6; // evaluates to false
5 == "5"; // evaluates to true

5 != 6; // evaluates to true
5 != "5"; // evaluates to false

The "strict equals" (===) and "strict not equals" (!==) compare both the value and the type. The "loose equals" (==) and "loose not equals" (!=) attempt to convert and compare values of different types. With the loose versions, the string '5' and the number 5 are considered "equal", which, in good code, is usually not what you want.

This is a fairly unique quirk of the JavaScript language.

You can read more about how == works if you're interested, but I'd recommend sticking with === and !== in nearly all cases.

Assignment

Change the operators (and only the operators) in the code so that each statement evaluates to true if it doesn't already.