Good evening all! I’m trying my hand at a x’s and o’s game. I’m stuck on the click logic. Here’s what I have.
let playerOne = true;
let box = document.querySelectorAll(":scope .box");
box.addEventListener(“click”, function() {
if (playerOne) {
box.textContent = “X”;
playerOne = false;
} else {
box.textContent = “O”;
playerOne = true;
}
});
My guess is that the .querySelectorAll isn’t functioning as I would expect it too. I’m trying to use it to select 9 .box classes in my html file.
Thank you!