Comparison Operators
In this lesson you are going to have the opportunity to interact with comparison operators. Comparison operators are used to Compare one value against another.
The Operators
< this Operator compares two values and determines if the first is less than the second
For example this statement would determine that the first is less than the second
5 < 10 = true
> this Operator compares two values and determines if the first is greater than the second
For example this statement would determine that the first is less than the second
5 > 10 = false
<= this Operator compares two values and determines if the first is less than or equal to the second
For example this statement would determine that the first is less than the second
5 <= 10 = true
5 <= 5 = true
>= this Operator compares two values and determines if the first is greater than or equal to the second
For example this statement would determine that the first is less than the second
5 >= 10 = false
5 >= 5 = true
== this Operator compares two values and determines if the first is equal to the second. We have already used a single equal symbol as an Assignment Operator. So to use it as a Comparison operator we need to double up equal symbols
For example this statement would determine that the first is equal to the second
5 == 5 = true
!= this Operator compares two values and determines if the first is not equal to the second. We have already used a single equal symbol as an Assignment Operator. So to use it as a Comparison operator we need to double up equal symbols
For example this statement would determine that the first is equal to the second
5 != 5 = false
The Operators
< this Operator compares two values and determines if the first is less than the second
For example this statement would determine that the first is less than the second
5 < 10 = true
> this Operator compares two values and determines if the first is greater than the second
For example this statement would determine that the first is less than the second
5 > 10 = false
<= this Operator compares two values and determines if the first is less than or equal to the second
For example this statement would determine that the first is less than the second
5 <= 10 = true
5 <= 5 = true
>= this Operator compares two values and determines if the first is greater than or equal to the second
For example this statement would determine that the first is less than the second
5 >= 10 = false
5 >= 5 = true
== this Operator compares two values and determines if the first is equal to the second. We have already used a single equal symbol as an Assignment Operator. So to use it as a Comparison operator we need to double up equal symbols
For example this statement would determine that the first is equal to the second
5 == 5 = true
!= this Operator compares two values and determines if the first is not equal to the second. We have already used a single equal symbol as an Assignment Operator. So to use it as a Comparison operator we need to double up equal symbols
For example this statement would determine that the first is equal to the second
5 != 5 = false