At this point, our game is fully usable. Users can add X
s and O
s and can see for themselves who has won or not. However, this is a computer game now and it should be programmed to determine who the winner is algorithmically.
Breaking down the problem of tic-tac-toe, one will realize that there are only 8 winning conditions in the game. We can create a handful of functions that will checkForWin
when a square is clicked. Once we have determined the winner, we can update the UI to announce that to the users.