GeezerVison is showing github.com — Arrays Iterators README.md update. · gurucharanD/JavaScript-Lessons@9f04136
File tree
Expand file treeCollapse file tree
Open diff view settings
Data_Structures/Arrays/Iterators
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: Data_Structures/Arrays/Iterators/README.md +14-7Lines changed: 14 additions & 7 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 |  |
2 | 2 |
|
3 | 3 | # Iterators |
4 | | -This MD file serves as example/template. It will be filled up soon. |
5 | | - |
6 | | -(for Bucky to fill up) |
| 4 | +**Simple Iteration** |
| 5 | +The way to iterate elements in javascript arrays is pretty straight forward: |
7 | 6 |
|
8 | | -# Course Documentation |
| 7 | + console.log(food[2]); |
9 | 8 |
|
10 | | -(this for me to fill up with every element that you use in lessons. syntax explaination and links for more) |
| 9 | +Array values are retrieved by index (starting at 0 not 1). |
| 10 | + |
| 11 | +**Iteration through loop** |
| 12 | +The best way to iterate an array is mathematically through a loop, like the example bellow: |
11 | 13 |
|
12 | | -## Element to explain |
| 14 | + // you can iterate over an array to access each individual element |
| 15 | + for(var i=0; i<food.length; i++){ |
| 16 | + console.log(i, food[i]); |
| 17 | + } |
| 18 | + |
| 19 | + |
13 | 20 |
|
14 | | -(for example console.log) |
| 21 | +# Course Documentation |
15 | 22 |
|
16 | 23 | ##Javascript functions |
17 | 24 |
|
|