JavaScript If Conditionals and Loops Flashcards
Give 6 examples of comparison operators.
> Greater Than < Less Than >= Greater Than Or Equal To == Two Values Are The Same === Strictly Equal To (Same data type and value) != Not Equal !== Strict no equal % Remainder
What data type do comparison expressions evaluate to?
Boolean Values
True -or- False
What is the purpose of an if statement?
If a condition is met, then then subsequent statements are executed in the code block
Is else required in order to use an if statement?
No
What are the three logical operators?
&& - Logical and, tests more than one condition
|| Logical or, tests at least one condition.
! - Logical Not, tests Takes a single Boolean value and inverts it.
How do you compare two different expressions in the same conduit?
Using Logical and &&
Logical or ||
What is the purpose of a loop?
They offer a quick and easy way to do something repeatedly.
What is the purpose of a condition expression in a loop?
The condition is about where the loop starts or stops
What does “iteration” mean in the context of loops?
Every time the process happens, that is the iteration
When does the condition expression of a while loop get evaluated?
Before each iteration
When does the initialization expression of a for loop get evaluated?
Before ANYTHING in the for loop
When does the condition expression of a for loop get evaluated?
Before each iteration in the for loop
When does the final expression of a for loop get evaluated?
After the loop code block has run
This happens before we return to the condition
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
break
What does the ++ increment operator do?
It adds and assigns 1 to the variable and becomes a new value