When no one wins, display a message about the result being a draw

This commit is contained in:
Alice Gaudon 2022-03-13 19:24:24 +01:00
parent c337a18e32
commit 355cec6300

View File

@ -2,10 +2,6 @@ import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
/*TODO
When no one wins, display a message about the result being a draw.
*/
function Square(props) {
const classNames = ['square'];
@ -156,6 +152,11 @@ function calculateWinState(squares) {
return {winner: squares[a], line: lines[i]};
}
}
if (squares.every(square => !!square)) {
return {winner: 'Draw :/', line: []};
}
return null;
}