1×
Become a member
to unlock all features

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

Create account
Autoplay

    Create a 2-Dimensional Grid for our Tic-Tac-Toe Game

    javascriptJavaScript

    Tic-tac-toe, like many grid-based games, relies upon a 2-dimensional array data structure to hold the state of our grid.

    A grid is a matrix. The outer array contains all the rows, and each row is an array of columns. Often each column value is referred to as a cell. In tic-tac-toe, we create a 3x3 grid of null values that will be replaced with Xs and Os as the user interacts with the game.