Mark As Completed Discussion

Implementing a Stack

Implementing a Stack

Here's a simple implementation of a stack. We can take it piece by piece, starting with the initial boilerplate setup:

1class Stack {
2  // Array is used to implement stack
3  constructor() {
4    this.items = [];
5  }
6
7  // Functions we'll need
8  // push(item)
9  // pop()
10  // peek()
11  // getSize()
12  // print()
13}