Skip to content

Commit 538404c

Browse files
committed
Fix win/draw logic
1 parent 79c7064 commit 538404c

File tree

1 file changed

+10
-2
lines changed
  • bootcamp_content/projects/tic-tac-toe/exercises/ticky-tac

1 file changed

+10
-2
lines changed

bootcamp_content/projects/tic-tac-toe/exercises/ticky-tac/example.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ function checkForDraw() {
4545
}
4646
}
4747

48+
function checkForGameOver() {
49+
checkForWin()
50+
if (gameOver) {
51+
return
52+
}
53+
54+
checkForDraw()
55+
}
56+
4857
function toggleTurn() {
4958
turn = turn == 'o' ? 'x' : 'o'
5059
}
@@ -65,7 +74,6 @@ function handlePlacement(event) {
6574
square.content = turn
6675
square.elem.innerHTML = turn
6776

68-
checkForWin()
69-
checkForDraw()
77+
checkForGameOver()
7078
toggleTurn()
7179
}

0 commit comments

Comments
 (0)