JavaScript Loops Worksheet

Questions

Question 1

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

A while loop runs as long as a condition is true. A for loop is best when you know how many times to run the loop.

Question 2

What is an iteration?

Each time the code in the loop body executes.

Question 3

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

It refers to the item that the loop is currently running.

Question 4

What is a 'counter variable'?

It's determine how many times the loop iterates.

Question 5

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

Terminates a loop before it's completed.

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.