JS Loops Flashcards
How do you iterate through the keys of an object?
Use for…in loop
What does the ++ increment operator do?
Increases the variable by 1:
If before variable > value gets incremented before
If after, value gets incremented after
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
Break
What is the purpose of a condition expression in a loop?
To return a true and false value, so the loops know when to run a code block.
When does the final expression of a for loop get evaluated?
At the end of each iteration
What does “iteration” mean in the context of loops?
When loop starts and then ends
When does the condition expression of a while loop get evaluated?
In the beginning at the condition statement before code block is run
When does the initialization expression of a for loop get evaluated?
Only happens one time, right in the beginning before anything happens.
When does the condition expression of a for loop get evaluated?
After initialization and before code block happens. When condition is met, code block will run.
What is the purpose of a loop?
For repetition