js loops Flashcards
What is the purpose of a loop?
To repeat code in a controlled way
What is the purpose of a condition expression in a loop?
To have a condition where the loop ends
What does “iteration” mean in the context of loops?
A single execution of the code inside the loop
When does the condition expression of a while loop get evaluated?
Before the each iteration
When does the initialization expression of a for loop get evaluated?
Before the condition expression and first iteration
When does the condition expression of a for loop get evaluated?
Before each iteration
When does the final expression of a for loop get evaluated?
In between iterations starting after the first iteration and before the second (if they exist)
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?
number++; // number = number + 1;
increments number by one
How do you iterate through the keys of an object?
for…in loop
for (const x in object) { }