Misconception: The update in the index in a for loop (i.e., the third part of the for loop control statement) happens after the all the steps inside of the loop have happened.

  • Students often incorrectly read straight across the control statement of the for loop and believe the three execute in order to start the loop.
  • The last part of the for loop control statement, updating the index, does not update until after the loop runs through once.

More about this tip

External Source

Interview with Dani McAvoy