Skip to content

Commit

Permalink
fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
atchutchi committed May 16, 2023
1 parent bfb297f commit 14d28c5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions assets/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let currentPlayer = "X";
for (let i = 1; i <= 9; i++) {
const cell = document.getElementById(`cell${i}`);
cell.addEventListener("click", handleCellClick);
}
}

// Add event listeners to the game mode selection buttons.
document.getElementById("playerVsPlayer").addEventListener("click", () => handleGameModeSelection("playerVsPlayer"));
Expand Down Expand Up @@ -73,21 +73,21 @@ function handleCellClick(event) {
// If no one won as of yet, the current player is changed.
currentPlayer = currentPlayer === "X" ? "O" : "X";
}
}
}

// Function to determine whether a player won
function checkWin(player) {
return winningCombinations.some(combination =>
combination.every(index => board[index] === player)
);
}
}

// function to prepare the game for the upcoming round
function startNextRound() {
// Clean all
board = ["", "", "", "", "", "", "", "", ""];
for (let i = 1; i <= 9; i++) {
document.getElementById(cell${i}).textContent = "";
document.getElementById(`cell${i}`).textContent = "";
}

// Change the player
Expand Down
16 changes: 8 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<li><a href="#">Rules</a></li>
</ul>
</nav>
</header>
<main>
</header>
<main>
<section>
<h1>XOX Winners</h1>
<div class="game-setup">
Expand Down Expand Up @@ -56,10 +56,10 @@ <h2>Scores</h2>
<h2>Rules</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris nec nisl vitae est aliquet vulputate. Pellentesque vitae arcu lorem. Nulla facilisi.</p>
</section>
</main>
<script src="assets/js/scripts.js"></script>
<footer>
<p>Copyright &copy; Atchutchi Ferreira</p>
</footer>
</main>
<script src="assets/js/scripts.js"></script>
<footer>
<p>Copyright &copy; Atchutchi Ferreira</p>
</footer>
</body>
</html>
</html>

0 comments on commit 14d28c5

Please sign in to comment.