+
+
{status}
-
-
-
+ {/*
*/}
+ {this.renderSquare(0)}
+ {/*
this.setState({players1: this.handleClick()})}>*/}
+ {/*{this.playerTurn}
*/}
+ {/*
*/}
+ {this.renderSquare(1)}
+ {/*
*/}
+ {this.renderSquare(2)}
-
-
-
+ {/*
*/}
+ {this.renderSquare(3)}
+ {/*
*/}
+ {this.renderSquare(4)}
+ {/*
*/}
+ {this.renderSquare(5)}
-
-
-
+ {/*
*/}
+ {this.renderSquare(6)}
+ {/*
*/}
+ {this.renderSquare(7)}
+ {/*
*/}
+ {this.renderSquare(8)}
+
);
}
}
ReactDOM.render(
, document.getElementById('tic-tac-toe'));
+
+function calculateWin(squares){
+ const lines = [
+ [0, 1, 2],
+ [3, 4, 5],
+ [6, 7, 8],
+ [0, 3, 6],
+ [1, 4, 7],
+ [2, 5, 8],
+ [0, 4, 8],
+ [6, 4, 2],
+ ];
+ for(let i = 0; i