JavaScript Loops Worksheet

Questions

Question 1

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

A while loop continues as long as the condition is true, but a for loop generally has a set amount of times to repeat. You can use criteria to set the amount of time.

Question 2

What is an iteration?

An iteration is one pass through the loop.

Question 3

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

The current element is the element that is currently being passed through in the loop.

Question 4

What is a 'counter variable'?

A counter variable keeps track of how many times the loop has occurred.

Question 5

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

The break statement stops the loop.

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.