Created
January 5, 2025 18:33
-
-
Save danicunhac/fe2338a418fdacfe3dfdf5582ad20957 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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