JavaScript exercise - chess game from scratch