Skip to content

Commit a491f21

Browse files
committed
3rd step: Add draw case into game cases.
1 parent 5695711 commit a491f21

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Game extends React.Component {
3434
}
3535

3636
render() {
37+
const MAX_LEN = 9;
3738
this.history = this.state.history;
3839
this.current = this.history[this.history.length-1];
3940
this.winner = calculateWinner(this.current.squares); // Due Game Component now have the squares state this Component will calculateWinner.
@@ -46,10 +47,11 @@ class Game extends React.Component {
4647
</li>
4748
);
4849
});
49-
5050
let status;
5151
if (this.winner) {
5252
status = 'Winner: ' + this.winner;
53+
} else if (this.history.length-1 === MAX_LEN) {
54+
status = 'Draw...';
5355
} else {
5456
status = 'Next Player: ' + (this.state.xIsNext ? 'X' : 'O');
5557
}

0 commit comments

Comments
 (0)