Tic Tac Toe implementation in javascript