For loops are used when we know how many times we want a particular set of instructions to run. For loops allow us to communicate:

  • When to start our loop
  • How many times to repeat
  • What to do after repeating

A for loop which starts at 2 and counts up to 5 might look like:

for (start at 2; stop at 5; go up by 1){ print current number } // Would output: 2 3 4 5

For loops let us repeat actions a certain number of times. Now that we know how to use for loops, let’s practice!


Use the new for loop block to help Codey reach their goal. The for loop block will make Codey repeat an action a certain number of times.

Codey needs to move to the right and down a certain number of times. You can two for loops to accomplish this.
For 3 loops Move right For 6 loops Move down

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?