Im trying to write a tic tac toe game with javascript and there is a mistake in the code that doesn't get displayed in the console can someone please tell me what is wrong with the script.
var box = document.getElementById("box");
var subBox = document.getElementsByClassName("subBox");
var num = 0;
function turn() {
if (num % 2 == 0) {
document.subBox.this.innerHTML = "X";
num++;
} else if (num % 2 == 1) {
document.subBox.this.innerHTML = "O";
num++;
}
}
for (i = 0; subBox.length < i; i++) {
subBox[i].addEventListener('click', turn());
}