for(statement 1; statements 2; statement 3) {
}
This is the basic structure of the for loop. We start with the keyword ‘for’, followed by three statements, which define how many times our loop runs.
Statement 1 is a piece of code you will write that will be run BEFORE the loop runs.
Statement 2 is a condition statement, which will decide whether or not the loop should run.
Statement 3 is a piece of code you will write that will be run AFTER your code inside the loop is run.
Let’s look at an example and break down exactly how it all works: