Loops Flashcards

1
Q

What is the purpose of a loop?

A

Allow you to repeat a process over and over without having to write the same (potentially long) instructions each time you want your program to perform a task.

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

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

A

an expression that is tested each time the loop repeats (on/off switch)

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

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

A

One completed execution of the code in a loop

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

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

A

Before the executing statement.

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

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

A

Executed one time before the code block

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

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

A

After the initialization and after each loop

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

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

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

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

What does the ++ increment operator do?

A

Adds one a value

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

How do you iterate through the keys of an object?

A

Use the for in loop

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