Hello Sir, modifying this solution to make it work for a 4x4 tic tac toe game but I am having some trouble getting it to work and I'm not quite understanding why. Any help would be highly appreciated. I will list the steps I have taken in order to accomplish that and maybe you can tell me where I went wrong.
Adding more cells to our board by modifying both the HTML and CSS.
Modifying the win conditions in order to accommodate for the change in board size
for (let i = 0; i <= 15; i++) {
const winCondition = winningConditions[i];
let a = gameState[winCondition[0]];
let b = gameState[winCondition[1]];
let c = gameState[winCondition[2]];
let d = gameState[winCondition[3]];
if (a === '' || b === '' || c === '' || d === '') {
continue;
}
if (a === b && b === c && c === d) {
roundWon = true;
break;
}
}
Lastly I modified the gamestate to reflect the additional cells.
Like I said any help would be greatly appreciated! If you would like to look at the full code let me know! Thank you for your time!
Hello Sir, modifying this solution to make it work for a 4x4 tic tac toe game but I am having some trouble getting it to work and I'm not quite understanding why. Any help would be highly appreciated. I will list the steps I have taken in order to accomplish that and maybe you can tell me where I went wrong.
Like I said any help would be greatly appreciated! If you would like to look at the full code let me know! Thank you for your time!
Sorry, realized immediately after posting this that my for-loop should look like this. Got a little confused on what exactly was taking place.
for (let i = 0; i <= 9; i++)
Everything works perfect now. Thank you.
Ah the rubber duck debugging at it's finest :)
Glad you sorted it out!