Я пытаюсь присвоить значение boxSpaces[0]
переменной результата в функции decalreWinner()
, но назначение не выполняется.
function assignSpace(mark, box) {
const image = document.createElement("img");
const src = mark === "x" ? X_IMAGE_URL : O_IMAGE_URL;
image.src = src;
box.appendChild(image);
box.removeEventListener("click", changeToX);
const id = parseInt(box.dataset.id);
boxSpaces[id] = mark;
}
function isGameOver() {
const length = emptyBoxes.length;
if (length <= 0) {
declareWinner();
return true;
} else {
false;
}
}
function declareWinner() {
const result = "";
if (boxSpaces["0"] === boxSpaces["1"] && boxSpaces["1"] === boxSpaces["2"]) {
result = boxSpaces["0"];
console.log(result);
}
return result;
}