GeezerVison is showing github.com — Add introduction for loops · yuezhangda/javascript@31329ed
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: SUMMARY.md +4-1Lines changed: 4 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
16 | 16 | * [If](conditional/if.md) |
17 | 17 | * [Else](conditional/else.md) |
18 | 18 | * [Comparators](conditional/comparators.md) |
19 | | - * [Concatenate](conditional/concatenate.md) |
| 19 | + * [Concatenate](conditional/concatenate.md) |
| 20 | +* [Loops](loops/README.md) |
| 21 | + * [For](loops/for.md) |
| 22 | + * [While](loops/while.md) |
Collapse file
Copy file name to clipboard +21Lines changed: 21 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +# Loops |
| 2 | + |
| 3 | +Loops are repetitive conditions where one variable in the loop changes. Loops are handy, if you want to run the same code over and over again, each time with a different value. |
| 4 | + |
| 5 | +Instead of writing: |
| 6 | + |
| 7 | +```javascript |
| 8 | +doThing(cars[0]); |
| 9 | +doThing(cars[1]); |
| 10 | +doThing(cars[2]); |
| 11 | +doThing(cars[3]); |
| 12 | +doThing(cars[4]); |
| 13 | +``` |
| 14 | + |
| 15 | +You can write: |
| 16 | + |
| 17 | +```javascript |
| 18 | +for (var i=0; i < cars.length; i++) { |
| 19 | + doThing(cars[i]); |
| 20 | +} |
| 21 | +``` |