JS Loops Flashcards

1
Q

How do you iterate through the keys of an object?

A

Use for…in loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the ++ increment operator do?

A

Increases the variable by 1:
If before variable > value gets incremented before
If after, value gets incremented after

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the purpose of a condition expression in a loop?

A

To return a true and false value, so the loops know when to run a code block.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When does the final expression of a for loop get evaluated?

A

At the end of each iteration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does “iteration” mean in the context of loops?

A

When loop starts and then ends

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When does the condition expression of a while loop get evaluated?

A

In the beginning at the condition statement before code block is run

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When does the initialization expression of a for loop get evaluated?

A

Only happens one time, right in the beginning before anything happens.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When does the condition expression of a for loop get evaluated?

A

After initialization and before code block happens. When condition is met, code block will run.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the purpose of a loop?

A

For repetition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly