JavaScript Loops Worksheet

Questions

Question 1

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

A while loop will go on forever until the boolean expression is false
A for loop lets you set a veriable, boolean expression and an incrementer. It will loop until the expression is false.

Question 2

What is an iteration?

An interation is 1 run through of a loop.

Question 3

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

Element we are surrently working on in the loop. Looping in an array, the second interation the current element would be the index of 1.

Question 4

What is a 'counter variable'?

A counter variable is the variable that increments per loop iteration until the loop is false.

Question 5

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

Break, breaks out of the loop and stops the looping process

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.