I am currently working on creating a Tic Tac Toe game using JavaScript, and I want to log all the elements that do not have a URL assigned to them yet. However, when I try to implement this, it logs all elements including those that already have a URL. I am wondering why this is happening.
const cells = document.querySelectorAll("img");
let boxes = [];
cells.forEach(function (cell) {
cell.addEventListener("click", playerChoice, false);
});
function playerChoice() {
this.src = "Small_uppercase_letter_X.svg.png";
setTimeout(1000, computerChoice());
}
function computerChoice() {
for (let cell of cells) {
if (cell.src != "Small_uppercase_letter_X.svg.png") {
console.log(cell);
}
}
}