Skip to content

Instantly share code, notes, and snippets.

@danicunhac
Created January 5, 2025 18:33
Show Gist options
  • Save danicunhac/fe2338a418fdacfe3dfdf5582ad20957 to your computer and use it in GitHub Desktop.
Save danicunhac/fe2338a418fdacfe3dfdf5582ad20957 to your computer and use it in GitHub Desktop.
class Stack {
constructor(initialStack = []) {
this.stack = initialStack;
}
get() {
return this.stack;
}
pop() {
return this.stack.pop();
}
push(num) {
return this.stack.push(num);
}
}
function main() {
const stack = new Stack([1, 2, 3]);
stack.pop();
stack.push(4);
return stack.get();
}
console.log(main());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment