DEV Community

rodman864
rodman864

Posted on

Loops

What is the use of a counter variable?
It is used to track the number of times a block of commands is ran.

What happens when a counter variable reaches or exceeds a specified value?
When it reaches or exceeds a specific value, the loop stops.

Which is the most common counter variable?
The most common counter variable is i.

What is a command block?
It is a set of JavaScript commands enclosed within a set of curly braces.

Which is the main difference between a while loop and a for loop?
The main difference is the for loops are used whenever you have a counter variable. The while loops are used with conditions.

Top comments (0)