loops Flashcards

1
Q

What is the purpose of a loop?

A

Loops check a condition.

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

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.

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

everytime it executes or loops.

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

At the beginning, before the code block.
The while loop loops through a block of code as long as a specified condition is true.

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

Expression 1 is executed (one time) before the execution of 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

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

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

Expression 3 is executed (every time) after the code block has been executed.

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 or continue.

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 1 to variable specified.

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

The JavaScript for…in statement loops through the properties of an object.

for (let variable in object) {
// code to be executed
}

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