For loop
This lesson disucsses the concepts of for loop and nested for loop using examples and illustrations
We'll cover the following...
A for
loop is great for doing things a certain amount of time. It’s like a while
loop but the increment is included with the condition.
Syntax
A for
loop is set up like this:
Press + to interact
for (Initialization; Condition; Increment){// Code}
- Initialization - Makes a new local variable that can only be used in the loop.
- Condition - The loop only runs when the condition is true.
- Increment - How the variable changes every time the loop runs.