Loops Flashcards
What is the purpose of a loop?
Allow you to repeat a process over and over without having to write the same (potentially long) instructions each time you want your program to perform a task.
What is the purpose of a condition expression in a loop?
an expression that is tested each time the loop repeats (on/off switch)
What does “iteration” mean in the context of loops?
One completed execution of the code in a loop
When does the condition expression of a while loop get evaluated?
Before the executing statement.
When does the initialization expression of a for loop get evaluated?
Executed one time before the code block
When does the condition expression of a for loop get evaluated?
After the initialization and after each loop
When does the final expression of a for loop get evaluated?
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?
Adds one a value
How do you iterate through the keys of an object?
Use the for in loop