A situation can be evaluated by comparing the values with:
==
: is equal to (used for numbers, strings, or Booleans)!=
: is not equal to (used for numbers, strings, or Booleans)===
: strict equal to (used to compare two values to check same data TYPE and VALUE)!==
: strict not equal to (used to compare two values to check same data TYPE and VALUE)
Comparison operators usually return true or false. Logical operators allows you to compare the results of more than one comparison operator.
&&
: logical not||
: logical or!
: logical not
Loops
There are three types
- For: used when you run code a specific number of times, it is usually a counter
- While: used when you dont know if a code should run
- Do While: similar to while loop except it will run the statement inside its curlies even if the condition evaluates to false
Lopps are structured as so:
LOOP (INITIALIZATION; CONDITION; UPDATE){}
`
The operator +=
adds the new content to the variable after it. Basically, if a variable has been declared, using this operator with the updated value following it will set that variable equal to that update…if that makes sense.
Syntax for the loops:
while(true){ ACTION - (until not true)}
for (this;many;times){ACTION}
With the for loop in terms of steps this is what the cpu is doing:
for (1st; 2nd (if true); update to 4th){then do 3rd}