GeezerVison is showing github.com — Merge remote-tracking branch 'refs/remotes/buckyroberts/master' · MorrielAlexis/JavaScript-Lessons@0e70b8f
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 +7-2Lines changed: 7 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -# Title |
| 1 | +# Stacks |
2 | 2 |
|
3 | | -Description |
| 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. |
| 7 | + |
| 8 | + |
Collapse file
Copy file name to clipboardExpand all lines: Data_Structures/Stacks/main.js +9-4Lines changed: 9 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,7 +13,7 @@ function Stack() { |
13 | 13 | return items.length == 0; |
14 | 14 | }; |
15 | 15 |
|
16 | | - // view last item added to stack |
| 16 | + // return last item added to stack |
17 | 17 | this.peek = function () { |
18 | 18 | return items[items.length - 1]; |
19 | 19 | }; |
@@ -39,8 +39,13 @@ let buckysStack = new Stack(); |
39 | 39 | console.log(buckysStack.isEmpty()); |
40 | 40 |
|
41 | 41 | buckysStack.push(87); |
42 | | -buckysStack.push(71); |
43 | | - |
44 | | -console.log(buckysStack.peek()); |
45 | 42 | buckysStack.push(29); |
| 43 | +buckysStack.push(71); |
46 | 44 | buckysStack.print(); |
| 45 | +console.log(buckysStack.peek()); |
| 46 | + |
| 47 | +console.log('--------------------'); |
| 48 | + |
| 49 | +console.log(buckysStack.isEmpty()); |
| 50 | +buckysStack.clear(); |
| 51 | +console.log(buckysStack.isEmpty()); |