Javascript version of a well-known game