Please enable JavaScript to use CodeHS

Video Game Design in JavaScript (2022)

Lesson 1.9 For Loops

Description

This lesson teaches students how to use for loops in their programs. The for loop allows you to repeat a specific part of code a fixed number of times.

We write for loops like this:

for(var i = 0; i < 4; i++)
{
    // Code to be repeated 4 times
}

Objective

Students will be able to…
* Create for loops to repeat code a fixed number of times
* Explain when a for loop would be a useful tool
* Utilize for loops to write programs that would be difficult / impossible without loops