Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.