Tic-Tac-Toe in JavaScript

Build a tic-tac-toe game

IntermediateMini ProjectsExample 12 of 20
tic-tac-toe.js
1class TicTacToe {
2 constructor() { this.board = Array(9).fill(null); this.currentPlayer = 'X'; }
3 makeMove(index) { if(!this.board[index]) { this.board[index] = this.currentPlayer; this.currentPlayer = this.currentPlayer === 'X' ? 'O' : 'X'; } }
4 checkWinner() { /* Check win conditions */ return null; }
5}

Output

// Tic-tac-toe game

What's going on

Tic-Tac-Toe is a classic game implementation.