javascript-loops Flashcards
What is the purpose of a loop?
to repeat a task a specific number of times
What is the purpose of a condition expression in a loop?
the expression determines how many times the code block will be run
What does “iteration” mean in the context of loops?
the process of repeating a set of instructions for a specific number of times or until a specific condition is met. i.e. if a loop runs 2 times it is 2 iterations.
When does the condition expression of a while loop get evaluated?
The condition expression of a while loop is evaluated at the beginning of each iteration. This means that the code inside the while loop will only be executed if the condition evaluates to true. If the condition evaluates to false, the loop will terminate and control will be passed to the code that follows the while loop.
When does the initialization expression of a for loop get evaluated?
The initialization expression of a for loop is typically evaluated at the beginning of the first iteration of the loop. This means that the code in the initialization expression is executed only once, before the loop begins.
When does the condition expression of a for loop get evaluated?
The condition expression of a for loop is typically evaluated at the beginning of each iteration of the loop. This means that the code inside the for loop will only be executed if the condition evaluates to true.
When does the final expression of a for loop get evaluated?
The final expression of a for loop is typically evaluated at the end of each iteration of the loop.
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
break because it is falsey
What does the ++ increment operator do?
the ++ increment operator is used to increase the value of a variable by one
How do you iterate through the keys of an object?
for in loop