Often you want to compare a value of one variable with one of another variable, or the value of a variable against a literal value, for example the value in an if-statement.
Example for a comparison is if you want to compare the value of the day of week to “Sunday”, you can do this by checking todaysDate == “Thursday”.
Don’t mix up ‘=’ with ‘==’, the first is an assignment, the second one is a comparison.
Comparisons | |
x != y x > y x >= y x < y x <= y x && y x || y !x |
True if x and y are not equal True if x is greater than y True if x is greater or equal to y True if x is less than y True if x is less or equal to y True if x and y are true True if x or y are true True if x is false |
Post Your Comment