๐ง Tic Tac Toe โ A Classic Game Reimagined in JavaScript
๐ Live Demo: Play Now
๐๏ธ Source Code: GitHub Repo
๐ Part of My Learning Journey: Learning Curve Showcase
๐ฏ Project Overview
The Tic Tac Toe Game is one of the foundational JavaScript projects I built as part of my frontend learning journey. It combines DOM manipulation, game logic, and conditional rendering to deliver a fun and interactive browser-based game.
It supports both:
- ๐ฅ Two-player mode
- ๐ค Play against the bot (single-player mode)
This project is part of my learning-curve initiative where I build real projects to reinforce key frontend concepts.
๐งฉ Features
- โ 3ร3 interactive grid
- ๐ Turn-based play with automatic switching
- ๐ค Single-player mode with a basic bot
- ๐ง Win and draw detection
- ๐ "New Game" button to reset
- ๐ฅ๏ธ Responsive layout for different screen sizes
- ๐ก Status indicator (shows turn, win, or draw)
๐ ๏ธ Tech Stack
- HTML โ structure of the board and UI
- CSS โ styling, layout, and responsiveness
- JavaScript โ logic, state handling, interactivity
๐ง Key Learnings
Hereโs what I learned and practiced through this project:
DOM Manipulation
Handling element selection, updating content, and applying styles dynamically using JavaScript.Game State Management
Tracking game status (win/draw/turns) using arrays, conditions, and functions.Event Handling
UsingaddEventListener
for cell clicks, and updating UI based on logic.Separation of Concerns
Writing modular code โ separating game logic, UI updates, and event handlers.Implementing a Basic Bot
I added a simple bot that selects a random empty cell after the player's move. This introduced me to conditional AI logic.
๐งช How It Works
- The board is a 3ร3 grid of clickable cells.
- Two modes are supported: Player vs Player or Player vs Bot.
- On each turn:
- The player's symbol (X or O) is added to the clicked cell.
- The game checks for a win using predefined winning patterns.
- If no win and the board is full, it's a draw.
- In bot mode, the computer auto-selects a random empty cell.
- Clicking "New Game" resets the board and status.
๐ Live Project
You can play it right now on GitHub Pages:
๐ฎ Play Tic Tac Toe
๐ Explore the Code
The full source code is available in my GitHub repo. Feel free to explore, fork, or suggest improvements:
๐ Tic Tac Toe โ GitHub Repository
๐ฎ Future Enhancements
Some possible upgrades I plan to work on:
- ๐ Add sound effects for clicks and wins
- ๐ Dark/light mode toggle
- ๐ง Improve bot using Minimax algorithm (make it unbeatable)
- ๐ Track X/O scores across rounds
- ๐จ Add animations or themes for visual enhancement
๐ค๏ธ Part of My Learning Curve Journey
This project is part of my learning-curve series โ a self-designed roadmap where I learn development by building real-world projects. You can explore other projects here:
๐ https://mohit-sharma-dadhich.github.io/learning-curve/#about
๐ Final Thoughts
Recreating this simple yet iconic game helped me gain confidence in:
- Structuring logic
- Handling user interactions
- Thinking about UI/UX
- Working with browser events
Itโs a small step, but every step adds up.
If you're learning JavaScript โ build something. Even Tic Tac Toe can teach you a lot.
Thanks for reading! Feel free to leave feedback or fork the repo if you want to expand this game with your own ideas!
Top comments (0)