Hi campers,
I am working on the TicTacToe project. I have been stuck for about a week trying to get my computerTurn function to work properly. In the 2 player game option, everything works great, however when you choose 1 player game, and make the first move (which shows up fine), the computer’s move doesnt show up. I have used a nested array called “grid” to link to the html to show the moves. I can see when i console.log the grid that the computer is picking a spot, I just can’t figure out how to target that spot properly and dislplay the “X” or “O” for the computer. Also, I noticed from the console.log(grid) that when I hit the “play again” button instead of refresh the page, the computer moves start the get buggy and not work properly the second time around.
My goal is to find a solution without changing the entire structure of my code. I have looked at other coder’s projects and can’t seem to make their logic work with my code structure. I am still fairly inexperienced, and I know there is probably something small I am missing, just can’t seem to put my finger on it.
Any help or advice would be greatly appreciated! Here is a link to my codepen:
Thanks in advance!