Skip to content

Commit

Permalink
Update insertPlayer input to change turns
Browse files Browse the repository at this point in the history
  • Loading branch information
xhjayoub committed Sep 15, 2024
1 parent ac5b654 commit 0c9eba4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
function gameBoard() {
let gameBoardArr = [[],[],[]];
const insertPlayerInput = (player, posArr) => gameBoardArr[posArr[0]][posArr[1]] = player;
let player = "X";
const insertPlayerInput = function(posArr) {
gameBoardArr[posArr[0]][posArr[1]] = player;
if (player === "X") {
player = "O";
} else {
player = "X";
}
};
const displayGameBoard = () => console.log(gameBoardArr);
return { insertPlayerInput, displayGameBoard };
}

0 comments on commit 0c9eba4

Please sign in to comment.