JavaScript Loops Worksheet

Questions

Question 1

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

The main differenece between a while loop and a for loop is that with a while loop we don't know how many times this loop will repeat. The for loop we should have a general idea of how many times the loop will run.

Question 2

What is an iteration?

When talking about loops, each time the code in the loop body executes it is called iteration.

Question 3

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

the 'current element' is the element in the array that is processed within the body of the loop.

Question 4

What is a 'counter variable'?

The counter varaiable is a part of the for loop and is used to determine how many times the loop will repeat.

Question 5

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

The break can be used to break out of a loop early. The break would be placed inside the body of the loop to be used after the code is excuted.

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.