Reading notes for Code Fellows!
Two types of operators are comparison operators and logical operators. Comparison operators evaluate a situation and return Boolean values of either true or false.
==
- is equal to!=
- is NOT equal to===
- strict equal to!==
- strict NOT equal to>
- greater than<
- less than>=
- greater than or equal to<=
- less than or equal toLogical operators compare the results of more than one comparison operator, also returning a Boolean value.
&&
- Logical AND||
- Logical OR!
- Logical NOTLoops are programming tools that check for a condition and run a specified block of code if the condition returns true. After executing the block of code, the loop checks the condition again and continues to repeat the block of code intil a check returns false. Then the loop is exited.
There are three common types of loops:
The for lopp uses a counter as a condition to instruct the code to run a specified number of times. The counter of a for loop consists of three parts: initialization, condition and update and is contained in the parenthesis following the for keyword. Here is an example of a for loop set up:
for (var i = 0; i < 10; i++) {
// Code goes here
}
var i = 0
- initialization the variable i is created only one time when the for loop is first run.i < 10
- condition the loop should continue to run until it reaches the specified number.i++
- update every time the loop completes the block of code it increments the counter.