GeezerVison is showing github.com — Working on courses · reprogram2098/JavaScript-Lessons@4a82799
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: Data_Structures/Arrays/main.js +1-10Lines changed: 1 addition & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -4,8 +4,6 @@ var food = ['bacon', 'corn', 'sausage']; |
4 | 4 | console.log(food[2]); |
5 | 5 | console.log(food.length); |
6 | 6 |
|
7 | | -console.log('----------'); |
8 | | - |
9 | 7 | // loop over an array |
10 | 8 | for(var i=0; i<food.length; i++){ |
11 | 9 | console.log(i, food[i]); |
@@ -17,33 +15,26 @@ food.forEach(function (index, item) { |
17 | 15 | console.log(item, index); |
18 | 16 | }); |
19 | 17 |
|
| 18 | +console.log('----------'); |
20 | 19 |
|
21 | 20 | // add new items to an array |
22 | 21 | food.push('tuna'); |
23 | 22 | console.log(food); |
24 | 23 |
|
25 | | -console.log('----------'); |
26 | | - |
27 | 24 | // remove item from the end of an array |
28 | 25 | var lastItem = food.pop(); |
29 | 26 | console.log(lastItem); |
30 | 27 | console.log(food); |
31 | 28 |
|
32 | | -console.log('----------'); |
33 | | - |
34 | 29 | // remove item from the beginning of an array |
35 | 30 | var firstItem = food.shift(); |
36 | 31 | console.log(firstItem); |
37 | 32 | console.log(food); |
38 | 33 |
|
39 | | -console.log('----------'); |
40 | | - |
41 | 34 | // add item to beginning of an array |
42 | 35 | food.unshift('apples'); |
43 | 36 | console.log(food); |
44 | 37 |
|
45 | | -console.log('----------'); |
46 | | - |
47 | 38 | // remove item by index position |
48 | 39 | var pos = 1; |
49 | 40 | food.splice(pos, 1); |
|
Collapse file
Copy file name to clipboardExpand all lines: README.md -1Lines changed: 0 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -12,7 +12,6 @@ Note: This is just for me *(Bucky)* to keep track of all my lessons on YouTube, |
12 | 12 | - promise |
13 | 13 | - prototypes |
14 | 14 | - recursion |
15 | | - - score |
16 | 15 | - **Data Structures** |
17 | 16 | - arrays |
18 | 17 | - dictionaries |
|