There is good advice in the answer by adrianton3. I noticed one other thing:
You may have already updated the structure of the board based on adrianton3's answer but instead of this:
let gameboard = []; // = ["*", "*", "*", "*", "*", "*", "*", "*", "*"];
let symbol = "*";
for (let i = 0; i < 9; i++) {
gameboard[i] = symbol;
}
it could be simplified to use Array.fill()
:
const symbol = "*";
const gameboard = Array(9).fill(symbol);
That way there is no need to loop through the board when initializing the default values.