1×
Become a member
to unlock all features

Create egghead account to access 5000+ tutorials and resources from expert developers.

Create account
Autoplay

    Preventing Impossible States and Checking for Draw Conditions

    javascriptJavaScript

    We should add some final touches to our tic-tac-toe game. We want to make sure that after a user has won, that it's impossible for them to put the game into a broken state. We can do that by adding a guard to our reducer.

    It would also be nice if the board automatically reset in the result of a draw. We can add a checkForDraw function that algorithmically determines if the game is drawn or not and automatically reset the grid data.