JavaScript exercise: snake game