Ultimate tic-tac-toe in javascript