We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 686747e commit f82f34eCopy full SHA for f82f34e
js/game.js
@@ -7,6 +7,7 @@ export default class Game {
7
#playerO
8
9
#onTurn = 'X'; // Odd rounds => X starts, even rounds => O starts
10
+ #end = false;
11
#xWins = 0;
12
#oWins = 0;
13
#ties = 0;
@@ -54,6 +55,12 @@ export default class Game {
54
55
}
56
57
#handleClick(e, index) {
58
+ if (this.#end) {
59
+ this.#end = false;
60
+ this.#resetBoard();
61
+ return;
62
+ }
63
+
64
// Square already taken
65
if (this.#state[index] !== '') {
66
return;
@@ -110,9 +117,9 @@ export default class Game {
110
117
this.#oWins++;
111
118
112
119
120
+ this.#end = true;
113
121
this.#saveScore(winner);
114
122
this.#updateScore();
115
- this.#resetBoard();
116
123
124
125
#saveScore(winner) {
0 commit comments