JavaScript for snake game