ticTactoe Game!

I challenge you …
PLSSS give your valuable feedback!!


  • If you want a challenge then I think you should make it keyboard accessible.
  • As I increase the text size the header section overlaps the tic tac toe board.
  • Don’t skip heading levels (i.e. don’t jump from h1 to h5).
1 Like

This plays very nicely and you’ve even gone the extra mile to implement an AI player! Well done, @GauravSingh9356! I also really like that you broke your code down into small functions.

Here are some ideas on how you could make the code more readable and maintainable:

1 - Try to really make it obvious for someone reading the code how it works on a high level. Arguably, the high level gameplay logic is in turnClick, but that function has various parts that obscure the logic. To understand the function, I have to figure out…

  • why it matters what the type of a square is
  • what arguments go into turn
  • what this means: (!checkWin(origBoard, huPlayer) && !checkTie())

All of those tasks are manageable, but together, they just make it a bit hard to figure out what’s going on.

2 - There are a couple of places within minmax that are repeated in the inverse - I think extracting those into separate functions would help.

3 - Wherever you can, separate DOM manipulation from game logic (i.e. they should live in separate functions

4 - Try to avoid abbreviating names. I took a stupid amount of time to figure out what huPlayer stands for and I’m still not sure about origBoard

I hope some of that is helpful. Good luck and happy coding!


Wow the A.I is literally unbeatable. Adding some animation to the game will make it more appealing. Giving the A.I a short (very short) period of time to choose will make it more realistic .

1 Like