+ 1
is someone who can help with my tic tac toe game (javascript) ? i really need help i'm stuck
i want to add a red color in the winning box and to display a score game using a span which will be updated each time a player wins a game, and also to display a popup message if a player has won. THIS is my code: https://code.sololearn.com/WhfNOgyur7gw/#html
4 Respuestas
+ 1
word limit exceed
Show your code here using code playground.
https://www.sololearn.com/post/75089/?ref=app
+ 1
thank you
+ 1
A.
Popup with alert
Display result with innerText
B.
1. in HTML, add
<p>
<span>X :</span>
<span id="XScore">0</span>
<span>;</span>
<span>O :</span>
<span id="OScore">0</span>
</p>
2. In JavaScript,
2.1 add a global object
var counter = {
"X" : 0,
"O" : 0,
};
2.2 Then in checkForWinner()
add
alert( move + " wins!");
document.getElementById(move + "Score").innerText = ++counter[move];
C. an edit as demo:
https://code.sololearn.com/WXW6KC32MzJ3/?ref=app
0
Thank you so much it's working perfectly