1) Assign index to a random number
2) Until index is an empty square, assign index to another random number
3) Put a "O" in that square
4) End the computer's turn
The computer should now instantly play a move after the player does his turn!
Here's a website with more information: https://www.w3schools.com/jsref/met_win_settimeout.asp
The computer's turn should now wait half a second after the player's turn.