Answer the question
In order to leave comments, you need to log in
How to catch an error in Tic Tac Toe?
There is a code for the game "Tic-Tac-Toe"
https://codepen.io/ArtemVedischev/pen/oEzwOa?edito...
I wrote it myself, please do not scold too much. I am just learning.
In a single game, sometimes the check for empty fields fails, the computer makes a move to an already occupied field.
Checking for empty fields occurs in the getEmptySquare() function. And based on this, the field for the move is selected.
What's wrong?
Answer the question
In order to leave comments, you need to log in
And if so?
function getEmptySquare() { // почему get, если функция ничего не возвращает?
// и почему square, если их там не один?
emptySquare = []
$('.item').each(function(){
if (!this.textContent.length) {
emptySquare.push(this.id)
}
})
console.log('emptySquare:', emptySquare)
}
In general, it’s cool for a start, but for good, more than half of it must be mercilessly thrown away, and the rest must be redone, and then added more. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question