this is how i did using for each loop
buttons.forEach((button) => {
button.addEventListener("click", () => {
console.log("box was clicked"); //simply making print box was clicked each time user clicks it
if (turnO){
button.innerText = ("O")// if first time a button is clicked it will show O
turnO = false; // after player O has taken a turn it will then become false
} else
button.innerText = ("X")
turnO = true;
});