Brain freeze - loop for tic tac toe game that takes click input

Hi there,

I am working on the tic-tac-toe game. I have the 2-human-player game up and running. That runs without creating a loop, more or less. Clicks drive the 2-player game progress forward.

Now I’m wanting to build in the computer-as-player section. I think I need to loop in order to enable the computer to take its turns. But I can’t figure out how to loop and also allow an open-ended period for human-player click input. In codepen, I can’t create a loop with open-ended breaks for input - codepen thinks it has detected an infinite loop.

I’m completely drawing a blank on how to approach the game flow portion of the project. I would be grateful for some guidance. Thank you!!

My pen is https://codepen.io/diver864/pen/QQdaOy