GeezerVison is showing github.com — Merge remote-tracking branch 'refs/remotes/buckyroberts/master' · MorrielAlexis/JavaScript-Lessons@ef511ad
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 clipboard +4-4Lines changed: 4 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | # Stacks |
2 | 2 |
|
3 | | -A stack is a basic data structure that can be logically thought as linear structure represented by a real physical |
4 | | -stack or pile, a structure where insertion and deletion of items takes place at one end called top of the stack. The |
5 | | -basic concept can be illustrated by thinking of your data set as a stack of plates or books where you can only take the |
6 | | -top item off the stack in order to remove things from it. |
| 3 | +A stack is a data structure that can be logically thought of as a real physical stack or pile, a structure where |
| 4 | +insertion and deletion of items takes place at one end only called the "top" of the stack. The basic concept can be |
| 5 | +illustrated by thinking of your data set as a stack of plates or books where you can only take the top item off the |
| 6 | +stack in order to remove things from it. |
7 | 7 |
|
8 | 8 |  |
Collapse file
Copy file name to clipboardExpand all lines: Data_Structures/Stacks/main.js +16-7Lines changed: 16 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
3 | 3 | function Stack() { |
4 | 4 | let items = []; |
5 | 5 |
|
6 | | - // remove all items in the stack |
| 6 | + // remove all items |
7 | 7 | this.clear = function () { |
8 | 8 | items = []; |
9 | 9 | }; |
@@ -13,25 +13,30 @@ function Stack() { |
13 | 13 | return items.length == 0; |
14 | 14 | }; |
15 | 15 |
|
16 | | - // return last item added to stack |
| 16 | + // return last item added |
17 | 17 | this.peek = function () { |
18 | 18 | return items[items.length - 1]; |
19 | 19 | }; |
20 | 20 |
|
| 21 | + // remove last item from end |
| 22 | + this.pop = function () { |
| 23 | + return items.pop(); |
| 24 | + }; |
| 25 | + |
21 | 26 | // display all items |
22 | 27 | this.print = function () { |
23 | 28 | console.log(items.toString()); |
24 | 29 | }; |
25 | 30 |
|
26 | | - // add item to end of stack |
| 31 | + // add item to end |
27 | 32 | this.push = function (element) { |
28 | 33 | items.push(element); |
29 | 34 | }; |
30 | 35 |
|
31 | | - // remove last item from stack |
32 | | - this.pop = function () { |
33 | | - return items.pop(); |
34 | | - } |
| 36 | + // get size of stack |
| 37 | + this.size = function () { |
| 38 | + return items.length; |
| 39 | + }; |
35 | 40 |
|
36 | 41 | } |
37 | 42 |
|
@@ -42,7 +47,11 @@ buckysStack.push(87); |
42 | 47 | buckysStack.push(29); |
43 | 48 | buckysStack.push(71); |
44 | 49 | buckysStack.print(); |
| 50 | + |
| 51 | +console.log('--------------------'); |
| 52 | + |
45 | 53 | console.log(buckysStack.peek()); |
| 54 | +console.log(buckysStack.size()); |
46 | 55 |
|
47 | 56 | console.log('--------------------'); |
48 | 57 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: README.md +14-2Lines changed: 14 additions & 2 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 | # Course Outlines |
4 | 4 |
|
@@ -46,6 +46,8 @@ Teach existing JavaScript data structures such as arrays, sets, and maps. Also t |
46 | 46 |
|
47 | 47 | ## ES6 Features |
48 | 48 |
|
| 49 | +[Watch Video Tutorials](https://www.youtube.com/watch?v=ZJZfIw3P8No&index=1&list=PL6gx4Cwl9DGBhgcpA8eTYYWg7im72LgLt) |
| 50 | + |
49 | 51 | Overview of all the new features, syntax, and changes in ES6. |
50 | 52 |
|
51 | 53 | - let |
@@ -58,8 +60,18 @@ Overview of all the new features, syntax, and changes in ES6. |
58 | 60 |
|
59 | 61 | *** |
60 | 62 |
|
61 | | -### Using ES6 |
| 63 | +## Using ES6 |
62 | 64 |
|
63 | 65 | To enable ES6 support in any JetBrains IDE *(such as WebStorm)*: |
64 | 66 | - File > Settings > Languages & Frameworks > JavaScript |
65 | 67 | - Select EMCAScript 6 |
| 68 | + |
| 69 | + |
| 70 | +## Links |
| 71 | + |
| 72 | +- [Support](https://www.patreon.com/thenewboston) |
| 73 | +- [thenewboston.com](https://thenewboston.com/) |
| 74 | +- [Facebook](https://www.facebook.com/TheNewBoston-464114846956315/) |
| 75 | +- [Twitter](https://twitter.com/bucky_roberts) |
| 76 | +- [Google+](https://plus.google.com/+BuckyRoberts) |
| 77 | +- [reddit](https://www.reddit.com/r/thenewboston/) |