JavaScript Loops Worksheet

Questions

Question 1

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

A while loop runs while a certian condition is true, once its false the loop stops. A for loop runs for a given ammount of iterations and then stops.

Question 2

What is an iteration?

an iteration is a single instance of a loop running, ie running the code block a single time.

Question 3

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

When iterating throught an array the current element is the index in the array the loop is at.

Question 4

What is a 'counter variable'?

The counter is used to increment

Question 5

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

Break stops the loop from running if a certian condition is met

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.