How to determine winner in Tic Tac Toe application

How to determine winner in Tic Tac Toe application



I have a question about the Tic Tac Toe application, and how you implement determining the winner in my code. What I’ve done so far to code the game is code the game as an HTML table with IDs of the form r[row number]c[column number]. Right now I’m simply just choosing random IDs via a table cell mouse click for the computer to run the game. I’m not implementing any unbeatable algorithm (such as minimax) because I want to get the core stories working first before moving onto more advanced things. With this in mind My question is, during each mouse run, how do I go about correctly choosing the winner of the game if there is one, and if there is a tie? I know it probably involves some column and row iteration but I am not sure how to go about it. I’ve looked at similar solutions on Stack Overflow but to be honest a lot of them are over my head and I’m not sure how to proceed. Any help would be appreciated and I can share my source code as well.

Thank you all again for your time,
Justin Reid


I would recommend running a function after each click that checks every winning possibility. You can do this by checking each box with the .html method, I would recommend this link:
Then combine that with @P1xt 's message above.