Help With The TicTacToe Project

I have two arrays ‘won1’ and ’ won2’ to compare with ‘win’ win is an array of arrays that have all the possible results to the winner. when I compare ‘won1’ to ‘win’ - once I’ve gained the game - it works and alerts that “X won”, but when the “O wins the game”, it doesn’t alert anything. I’m using a function in which I just call win and won1/won2.

Here’s my code on code pen:

it’s quite messy but I’m just trying things out.

Also, I have no idea how to make the game ‘unwinnable’, so any tips would be appreciated.

If I’m overcomplicating things, please tell me, I’ve done this all on my own so I didn’t come up with a better way to approach this challenge.

Yes I did, it turned out it was because the function executed only when I click events, then if the computer wins the game the function wouldn’t execute. I just added setTimeOut so the function would call itself every x seconds.

thanks for the code review, I will make the changes that you suggested, I’m still a beginner so I am currently struggling to get the code to work as opposed to writing better code xD though I always trying to figure out what’s the best way to do certain tasks :DD.