loops Flashcards
What is the purpose of a loop?
Loops check a condition.
What is the purpose of a condition expression in a loop?
If it returns true, a code block will run.
Then the condition will be checked again and if it still returns true,
the code block will run again.
It repeats until the condition returns false.
What does “iteration” mean in the context of loops?
everytime it executes or loops.
When does the condition expression of a while loop get evaluated?
At the beginning, before the code block.
The while loop loops through a block of code as long as a specified condition is true.
When does the INITIALIZATION expression of a for loop get evaluated?
Expression 1 is executed (one time) before the execution of the code block.
When does the CONDITION expression of a for loop get evaluated?
Expression 2 defines the condition for executing the code block. its evaluated after the loop has been initialized and at the beginning of every following iteration
When does the FINAL expression of a for loop get evaluated?
Expression 3 is executed (every time) after the code block has been executed.
Besides a return statement, which exits its entire function block, which keyword exits a loop before its CONDITION expression evaluates to false?
break or continue.
What does the ++ increment operator do?
adds 1 to variable specified.
How do you iterate through the keys of an object?
The JavaScript for…in statement loops through the properties of an object.
for (let variable in object) {
// code to be executed
}