JavaScript Loops Worksheet

Questions

Question 1

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

while loop: Repeats while a condition is true.
for loop: Repeats a set number of times.

Question 2

What is an iteration?

Iteration means repeating something. In programming, one iteration happens each time a loop runs.

Question 3

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

The current element is the item the loop is working on right now.

Question 4

What is a 'counter variable'?

A counter variable is a variable that keeps track of how many times a loop has run.

Question 5

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

The break statement stops the loop immediately, even if the loop wasn't finished yet.

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.