When no one wins, display a message about the result being a draw
This commit is contained in:
parent
c337a18e32
commit
355cec6300
@ -2,10 +2,6 @@ import React from 'react';
|
|||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
/*TODO
|
|
||||||
|
|
||||||
When no one wins, display a message about the result being a draw.
|
|
||||||
*/
|
|
||||||
|
|
||||||
function Square(props) {
|
function Square(props) {
|
||||||
const classNames = ['square'];
|
const classNames = ['square'];
|
||||||
@ -156,6 +152,11 @@ function calculateWinState(squares) {
|
|||||||
return {winner: squares[a], line: lines[i]};
|
return {winner: squares[a], line: lines[i]};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (squares.every(square => !!square)) {
|
||||||
|
return {winner: 'Draw :/', line: []};
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user