I’m struggling with how to keep track of which tic tac toe squares are occupied, particularly when it comes to the computer player. I need a way to keep the computer from putting an X or O on a space that’s already occupied.
I’ve tried removing occupied squares from an array as a way to keep track of them. I’ve also tried turning the square “off” with
and it works for the user, but the computer can still change it. Now I’m stuck.
Here’s the link to my codepen, if you’d like to look at all of the js. But be warned–I’ve made a bit of a mess.
Thank you in advance.