successfully translated ruby game into javascript