Implementing Stack and Queue using JS