Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

tic-tac-toe-js

0.0.2 • Public • Published

Tic Tac Toe

JavaScript tic tac toe game.

Usage

npm install tic-tac-toe-js

$ node

> var Game = require('tic-tac-toe-js').Game;
[Function Game]
> game = new Game;
{ xScore: 0, oScore: 0, winner: null }
> game.move('x', 1);
true
> game.move('o', 9);
true
> game.isFinished();
false
> console.log(game.toString());
X |   |
--+---+--
  |   |
--+---+--
  |   | O
> game.move('x', 4);
true
> game.move('o', 7);
true
> game.move('x', 4);
true
> console.log(game.toString());
X | X | O
--+---+--
X |   |
--+---+--
O |   | O
> game.move('x', 6);
true
> game.move('o', 8);
true
> console.log(game.toString());
X | X | O
--+---+--
X |   | X
--+---+--
O | O | O
> game.move('x', 5);
false
> game.isFinished()
true
> game.winnner
'O'

License

MIT

install

npm i tic-tac-toe-js

Downloadsweekly downloads

1

version

0.0.2

license

MIT

last publish

collaborators

  • avatar
Report a vulnerability