Great code, I'am just starting with JS so I find it very usefull. I add the next lines in order to set a color to every player.
function handleCellPlayed(clickedCell, clickedCellIndex) {
/*
We update our internal game state to reflect the played move,
as well as update the user interface to reflect the played move
*/
gameState[clickedCellIndex] = currentPlayer;
clickedCell.innerHTML = currentPlayer;
if ( currentPlayer == "X" ) {
document.querySelectorAll('.cell')[clickedCellIndex].style.color = "blue";
}else{
document.querySelectorAll('.cell')[clickedCellIndex].style.color = "red";
}
}
Great code, I'am just starting with JS so I find it very usefull. I add the next lines in order to set a color to every player.
function handleCellPlayed(clickedCell, clickedCellIndex) {
/*
We update our internal game state to reflect the played move,
as well as update the user interface to reflect the played move
*/
gameState[clickedCellIndex] = currentPlayer;
clickedCell.innerHTML = currentPlayer;
Hey Jeff, that's a great idea!
Always happy to see someone taking the tutorial a step further :)
I think it might be better use ===.