JavaScript Loops Worksheet

Questions

Question 1

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

A while loop holds a boolean expression in its arguments, but a for loop holds a counter variable, boolean expression, and increment counter.

Question 2

What is an iteration?

One pass through a loop.

Question 3

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

In the aspect of an array, it would be the current index position that the loop has landed on when cycling through. In a for loop, it is at what point the counter variable has been incremeneted to.

Question 4

What is a 'counter variable'?

The counter variable is the variable that increases or decreases every time a loop has completed a cycle. It keeps track.

Question 5

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

It exits the loop and continues with the preceeding code outside of the loop confines.

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.