Tic Tac Toe tech test undertaken as part of the Makers Academy tech test week.
The rules of tic-tac-toe are as follows:
- There are two players in the game (X and O)
- Players take turns until the game is over
- A player can claim a field if it is not already taken
- A turn ends when a player claims a field
- A player wins if they claim all the fields in a row, column or diagonal
- A game is over if a player wins
- A game is over when all fields are taken
Build the business logic for a game of tic tac toe. It should be easy to implement a working game of tic tac toe by combining your code with any user interface, whether web or command line.
I started with some research into hash tables in JavaScript to help fuel my design process. This helped me plan what data structures I wanted to use within my code. After this I set up my test framework.
- Create a game object which handles the players turns and ending the game.
- Create a board object which stores the players moves and displays them.
- Added the ability for the game object to print the winner to the screen when someone wins.
- Clone the repository
- Run
npm install
- Run
npm test
to see the tests and test coverage.