Comparison Operators: Evaluating Conditions
There are a few comparison operators, what they do is that they compare an item to the left of the operator to an item to the right of the operator, and then return (usually) a true or false result, for example:
==Which meansis equal towhile also ignoring the datatype, it only looks at the content, meaning what you see is what you compare.!=Which meansis NOT equal to, this also ignores datatypes and only compares the content.===This is astrict equal to, the difference between this and==is that this one also compares datatype in addition to content, making it morestrict.!==Same as===, just that it’sstrict NOT equal to.>As in normal math, it meansGreater than, this only compares numbers.<The same as>, just it meansless than>=This is the same as>, just that it has an extra option for being equal, meaning it checks if the number of the left is bigger or equal to the one of the left.<=same as>=, just the opposite direction if comparsion.Logical Operators
Comparison operators usually give you either
trueorfalse, and Logical Operators allow you to compare that result with another one. For example:&&Which is called alogical and, it more or less just means and, which is used to know if both items on the left and right aretrueand then returntrue, otherwise the result will befalse.||Which is called alogical or, this one just checks of either of the items on the left or right aretrue, and then returns atrueresult.- !
This one doesn’t compare two items, it only takes one item, and then flips it.
Loops
A loop, as the name suggests, is a code block that keeps on re-running and looping until a certain condition is fulfilled. Common types of loops include:
forThis runs the loop for a set amount of times, and is the most common type of loop, the condition is a number counter.whileThis is used when you don’t know how many times the loop should run, the condition here can be different things than just a counter.do whileThis loop is similar to thewhileloop, but there’s one key difference, this loop will always run at least once, contrary to thewhileloop which can sometimes (depending on the code) not run at all.
| 102 | |||||||
|---|---|---|---|---|---|---|---|
| Home | read01 | read02 | read03 | read04 | read05 | read06 | read07 |