JavaScript Loops Worksheet

Questions

Question 1

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

While loop are used when you don't know ahead of time how many times you'll loop. While a For loop is used when you know in advance how many times to loop.

Question 2

What is an iteration?

It is a repetition of a loop.

Question 3

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

It means that the current element is working in that iteration.

Question 4

What is a 'counter variable'?

It is used to count how many times a loop has run.

Question 5

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

It is used to terminate 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.