Returning minimum value in a Stack with O(1) using Javascript