We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 480ee2b commit 8d805c1Copy full SHA for 8d805c1
lib/stacks.js
@@ -1,15 +1,15 @@
1
class Stack {
2
constructor () {
3
- this.head = {};
+ this.top = {};
4
this.length = 0;
5
}
6
7
push(data) {
8
let node = {
9
value: data,
10
- prev: this.head
+ prev: this.top
11
};
12
- this.head = node;
+ this.top = node;
13
this.length++;
14
return this.length;
15
@@ -19,14 +19,14 @@ class Stack {
19
return undefined;
20
21
22
- let value = this.head.value;
23
- this.head = this.head.prev;
+ let value = this.top.value;
+ this.top = this.top.prev;
24
this.length--;
25
return value;
26
27
28
peek() {
29
- return this.head.value;
+ return this.top.value;
30
31
32
height() {
0 commit comments