Tic-Tac-Toe is a simple and fun game for 2 players, X and O. It is played on a 3x3 grid. Each player's goal is to make 3 in a row.
Fill 3 squares in a row vertically, horizontally or diagonally.
Players take turns placing their X or O, on an open square in the grid. The first player to make 3 of their own mark in a row vertically, horizontally, or diagonally wins the game. If all 9 squares are filled and neither player has 3 in a row, the game is considered a Tie.
-
Define the required variables used to track the state of the game:
-
Store cached element references on the page that will be accessed in code more than once in variables to make code more concise, readable, and performant:
-
Upon loading, the app should: 3.1) Call an initialize function to initialize the state variables 3.2) Render those values to the page 3.3) Wait for the user to click a square
-
Define the required constants
-
Handle a player clicking a square
-
Handle a player clicking the replay button