Javascript-loops Flashcards
1
Q
What is the purpose of a loop?
A
- To allow something do multiple times –> repeat.
2
Q
What is the purpose of a condition expression in a loop?
A
- to see if the code should stop.
3
Q
What does “iteration” mean in the context of loops?
A
- when the code runs from { to } –> that is 1st iteration.
4
Q
When does the condition expression of a while loop get evaluated?
A
- Before anything happens
- if that happens it goes into iteration of the code.
- then it gets checked again.
5
Q
When does the initialization expression of a for loop get evaluated?
A
- happens before anything and it only happens 1 time.
6
Q
When does the condition expression of a for loop get evaluated?
A
- after initialization and after incrementation.
7
Q
When does the final expression of a for loop get evaluated?
A
- At the end of the iteration
8
Q
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
A
- break.
9
Q
What does the ++ increment operator do?
A
- it increases the value of the variable. (loops do one value past the stop value to check if it needs to be stopped).
10
Q
How do you iterate through the keys of an object?
A
For in loop