Foundations

For Loops

For Loops

A for loop is useful when you know how many times the loop should run. The loop counter changes each time through the loop.

Your task: Use a for loop to add the numbers from 1 through 5 to the provided counts array. Log the array after the loop.

Prerequisites

  • variables
  • operators
  • arrays

Tests

  • counts contains the numbers 1 through 5
  • counts has exactly five entries
  • a for loop performs the repeated work
Loading...
Console

Run code to see output.