IntermediateJavaScript

Implement a stack

Implement a stack data structure with push, pop, and peek methods.

Examples

Input: const stack = new Stack(); stack.push(1); stack.push(2); stack.pop(); stack.peek();

Output: 1

Your Solution

Output

Click 'Run Code' to see the output