Explain solidity>modifying state

Array Indexing

Arrays let you access individual elements using square brackets and an index number.

Syntax:

arrayName[index]

Important: Array indices start at 0, not 1!



Our board has 9 positions (0-8):

[0] [1] [2]
[3] [4] [5]
[6] [7] [8]

Remember that the default state of a Cell is Cell.Empty

To mark the center square as X:

board[4] = Cell.X;



Task: Try setting the center square (position 4) to Cell.X in a new public makeMove() function.

Create makeMove function
0%
Requirements:
Creates public function makeMove
Has opening and closing braces
Sets board[4] to Cell.X