Relational Operators
Many if statements compare values
Use the operators below to compare values :
Operator | Example(s) | |
is equal to | == | if (name == "Betty") { ... } if (x == 0) { ... } if x == 1: ... |
is not equal to | != or <> | if (name != "Alan") { ... } if (num != 5) { ... } if num != 2: ... or if num <>2: ... |
lesser than | < | if (count < 10) { ... } if count < 10: ... |
greater than | > | if (length > 3.4) { ... } if length > 3.4: ... |
lesser than or equal to | <= | if (points <= 100) { ... } if points <= 100: ... |
greater than or equal to | >= | if (width >= 6.2) { ... } if width >= 6.2: ... |
Last updated