JavaScript Loops Worksheet

Questions

Question 1

What is the difference between a while loop and a for loop?

While loops continue to repeat as long as a boolean expression evaluates to true, and for loop allows you to execute a coe block specific number of times.

Question 2

What is an iteration?

Each time a code in the loop body executes, its an iteration.

Question 3

What is the meaning of the current element in a loop?

The one that is processed within the body of the loop.

Question 4

What is a 'counter variable'?

Ussed to determine how many times the loop iterates.

Question 5

What does the break; statement do when used inside a loop?

To exit the loop, even if it's true.

Coding Problems

Coding Problems - See the 'script' tag below this h3 tag. You will have to write some JavaScript code in it.

Always test your work! Check the console log to make sure there are no errors.