JavaScript cod for game