Please enable JavaScript to use CodeHS

CodeHS Glossary


For Loop JavaScript

A for loop lets us repeat code a **fixed number of times.** For example, if we want to move 10 spaces or put down 15 tennis balls, we would use a for loop. If we want to move to the wall, but don't know how far away the wall is, we would not use a for loop. A for loop looks like: for(var i = 0; i < 10; i++){ move(); } This calls the `move()` command 10 times, and does the same thing as writing. move(); move(); move(); move(); move(); move(); move(); move(); move(); move();