I'm trapped in Tic-Tac-Toe

I have copied my scores array and called it NotTaken. When I place a marker, I want to splice the placement from the NotTaken array. The problem I am having is that my Player is not splicing although the computer is splicing.

My code is heavy on console.log so that I can track these. The function I think I’m problems with is the updNotTaken().

Any help is appreciated. My pen is at https://codepen.io/KoniKodes/pen/KqyLML

Thank you for responding.
comp() is supposed to have the computer choose a place (that hopefully has not been taken)
status tracks -1 for player or 1 for computer in the placement of the board. It is used for assigning the winner.
scores array is the board spaces id #, and is replaced with “X” or “O” when a move is placed. It is used to track the winCheck function.

The notTaken is spliced per score when a space is placed so that when we come down the final two moves before the full board is a tie, and the computer doesn’t have a block or win, it will look at the random spaces available in the notTaken array and then place on the random choice.

The updNotTaken function is supposed to define what the indexOf the notTaken array is with the place value. That is what I think is not working…

Thank you again.

I don’t know if this is the problem but in updNotTaken you have

while (notTaken.indexOf(place) > -1) {
    notTaken.splice(notTaken.indexOf(place), 1);

It is generally a bad idea to change the array while iterating inside it. Maybe changing the while statement to an if will solve your problem.

Thank you. But now it’s back to stealing a space that’s already been taken when it’s has to choose between the last two moves without a block or win.

In looking at the console.log, it seems that it although it sees the place that my player chose, it does not attach it to the notTaken splice. On the other hand, it does see the computer placement and splices that. Yet, it looks to me as though both segments are the same.

You were correct!

I went back to keeping it simple and took out the Not Take array.

Here’s my new page: https://konikodes.github.io/TicTacToe/

Thank you for your help.

I have finally gotten out the Tic-Tac-Toe Trap! I did not think I was going to survive it.
Thanks to all of you for your support and suggestions.

Please take a look and let me know what you think.
https://konikodes.github.io/TicTacToe/

Thank you for your feedback. I do not understand why it is happening to you.
When I win I get congratulations and one song. When the computer wins I get The Computer has won, and a different song.
On the tie, I get We have a tie! and a different song.

I do have the computer set with a 2 second time out. I have problems with an immediate placement after a player moves, it hurts my eyes. How do I prevent others from cheating?

Thank you. What device are you using? What browser? I need to fix this.

I think I fixed it. Can you check again please?
I should not matter which marker you choose. You should be recognized now.

Thank you for bringing these to my attention. I thought I had solved all of these. They are why I’ve been trapped here for so long.

Did these happen after the game refreshed? Or was it as a new game? I remember one tester did it like 8 times and then mad about a memory error.

So I’m wondering what my refresh threshold is and if it is affecting the logic.

I don’t think the user story tells us how many times to refresh.