Operator | Description |
---|---|
== | equal to |
=== | equal value and equal type |
!= | not equal |
!== | not equal value or not equal type |
> | greater than |
< | less than |
>= | greater than or equal to |
<= | less than or equal to |
** How Can it be Used **
Comparison operators can be used in conditional statements to compare values and take action depending on the result
true && true returns true true && false returns false false && true returns false false && false returns false
- or | ||
> true | true returns true | |
> true | false returns true | |
> false | true returns true | |
> false | false returns false |
!true returns false !false returns true
** Loops are handy, if you want to run the same code over and over again, each time with a different value.**
The for loop if you need to run a code a specific number of time.
The while loop loops through a block of code as long as a specified condition is true.
The do/while loop is a variant of the while loop. This loop will execute the code block once, before checking if the condition is true, then it will repeat the loop as long as the condition is true.