mirror of
https://github.com/milk-net/milk-net.github.io.git
synced 2025-04-19 17:43:42 -05:00
Create script.js
This commit is contained in:
parent
897ff5e673
commit
063b8498a6
1 changed files with 10 additions and 0 deletions
10
assets/games/tictactoe/script.js
Normal file
10
assets/games/tictactoe/script.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
let board = ['', '', '', '', '', '', '', '', ''];
|
||||
let currentPlayer = 'X';
|
||||
|
||||
function makeMove(index) {
|
||||
if (!board[index]) {
|
||||
board[index] = currentPlayer;
|
||||
document.querySelectorAll('.cell')[index].textContent = currentPlayer;
|
||||
currentPlayer = currentPlayer === 'X' ? 'O' : 'X';
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue