Generic Stack Class
Medium · Classes
Finish the generic class Stack<T> that stores items in a private array.
- push(item): add to the top and return the new size
- pop(): remove and return the top item, or undefined if empty
- peek(): return the top item without removing it, or undefined if empty
- size(): return the number of items
runStack is already written: it replays operations on a Stack<number> and turns undefined into null.