Adding Stack using array datastructure in js