Please enable JavaScript to use CodeHS

AP Computer Science Principles in JavaScript

Lesson 1.11 For Loops

Description

In this lesson, students learn 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.

A for loops is written as follows:

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

Activities

These are all the activities included in the lesson

1.11.1 For Loops
1.11.2 For Loops Quiz
1.11.3 Repeated Move
1.11.4 Put Down Tennis Balls
1.11.5 Take 'em All
1.11.6 Dizzy Karel
1.11.7 For Loop Square
1.11.8 Lots of Hurdles