Data structures - How to implement stack in javascript?

The stack is a first in last out data structure. The below example takes input from the user and performs multiple stack operations.

Here is the complete code for your reference!