|
|
@ -73,9 +73,9 @@ Loops allow for repetitive or **iterative** tasks, and can save a lot of time an
|
|
|
|
### For Loop
|
|
|
|
### For Loop
|
|
|
|
|
|
|
|
|
|
|
|
The `for` loop requires 3 parts to iterate:
|
|
|
|
The `for` loop requires 3 parts to iterate:
|
|
|
|
- `counter` A variable that is typically initialized with a number that counts the number of iterations.
|
|
|
|
- `counter` A variable that is typically initialized with a number that counts the number of iterations
|
|
|
|
- `condition` Expression that uses comparison operators to cause the loop to stop when `true`
|
|
|
|
- `condition` Expression that uses comparison operators to cause the loop to stop when `true`
|
|
|
|
- `iteration-expression` Runs at the end of each iteration, typically used to change the counter value
|
|
|
|
- `iteration-expression` Runs at the end of each iteration, typically used to change the counter value
|
|
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
```javascript
|
|
|
|
// Counting up to 10
|
|
|
|
// Counting up to 10
|
|
|
|