logical operators in javascript
- equal to ==: compares to value to see if they are the same
- strict equal to ===: checks to see if to to values have the same type and and value
- not equal to != checks to value to see if they are different
- strict not equal !==: value and type cant be equal in this one.
- the greater than />
- less than <
- greater than or equal />=
- less than or equal <= they are all logical and and result in a true or false based on the values they are comparing. # and, or , not
- and (&&) needs two true statements to result in a true
- or (||) if one statement is true the result is true
- not (!) flips true to false and false to true
loops in javascript
loops check check a condition if its true they execute the codes in thier scope over and over until the condition is not met anymore, “false”.
three types of loops
- For loops: we use them when know exactly how many times we need to run the statement
- while loops: we dont know how many times to run, but we know that we should stop when a certain event happens
- do while: same as while except that it will run atleast one time if the condition is false
the logic of loops is provide in the figure and as they say a picture is woth a thousand words.
syntax
- do while :
- while:
- for:
loops key concepts
- break: this statement is used to stop the loop even if the condition is still true.
- continue: skips the itteration
- LOOPS & ARRAYS: Loops are very helpful when dealing with arrays if you want to run the same code for each item in the array