Skip to content

Instantly share code, notes, and snippets.

@linkstrifer
Created July 2, 2020 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linkstrifer/87136bef89419aace42dad0b95cb5fdd to your computer and use it in GitHub Desktop.
Save linkstrifer/87136bef89419aace42dad0b95cb5fdd to your computer and use it in GitHub Desktop.
class Stack {
constructor() {
this.items = [];
}
push(item) {
return this.items.push(item);
}
pop() {
return this.items.pop();
}
peek() {
return this.items[this.length - 1];
}
isEmpty() {
return this.items.length === 0;
}
clear() {
this.items = [];
}
size() {
return this.items.length;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment