Tic-tac-toe

Author
Svelte core team
Languages

Tic-tac-toe is a game for two players who take turns making space in a three-by-three grid with X or O. The player who succeeds in playing three of their marks in a horizontal, vertical, or diagonal row is the winner.

Source: Wikipedia

Build a tic-tac-toe game that is playable by two players.

Tic-tac-toe Example

Requirements

  • Players can take turns to place an X or a O on the board.
  • A player wins if three of their marks are in a horizontal, vertical, or diagonal row.
  • Display the current game status at the top: whose turn it is, winner (if any), or draw.
  • Add a "Reset" button to allow the game to be restarted at any time.

If you aren't familiar with the game, try out playing tic-tac-toe on Google.

Asked at these companies

Premium FeaturePurchase premium to see companies which ask this question.
View plans
The TypeScript Denial Tee — TypeScript love, "any" denialSponsor: SwagOverflow
The TypeScript Denial Tee — TypeScript love, "any" denial

You swear by TypeScript, but we all know what's lurking in your code. This black tee perfectly captures the silent shame of every front end dev who totally loves strict typing — until any saves the day. Clean, witty, and painfully relatable, it's the ultimate uniform for TypeScript warriors in denial.

Get yours now ->

The TypeScript Denial Tee — TypeScript love, "any" denialSponsor: SwagOverflow
The TypeScript Denial Tee — TypeScript love, "any" denial

You swear by TypeScript, but we all know what's lurking in your code. This black tee perfectly captures the silent shame of every front end dev who totally loves strict typing — until any saves the day. Clean, witty, and painfully relatable, it's the ultimate uniform for TypeScript warriors in denial.

Get yours now ->