AnshSA
July 16, 2024, 7:47am
1
Tell us what’s happening:
I don’t know why my code is not passing through
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
function resetGame() {
playerScore = 0;
computerScore = 0;
computerScoreSpanElement = "0";
playerScoreSpanElement = "0";
resetGameBtn.style.display = "none";
optionsContainer.style.display = "block";
roundResultsMsg = "";
winnerMsgElement = "";
};
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Challenge Information:
Review DOM Manipulation by Building a Rock, Paper, Scissors Game - Step 6
hi there!
you have missed some of the instrutions to code:
You can use the innerText
property to update the content of an element. To clear the content of an element, you can set the innerText
to an empty string.
and aslo the instructions for span elements:
Updates the playerScoreSpanElement
and computerScoreSpanElement
to display the new scores. *
you are updated the span elements to the string, not to the score.
AnshSA
July 16, 2024, 8:55am
4
@hasanzaib1389
Is this what you meant?
function resetGame() {
computerScore = 0
playerScore = 0
computerScoreSpanElement = playerScore
playerScoreSpanElement = computerScore
resetGameBtn.style.display = “hidden”
optionsContainer.styles.display = “block”
winnerMsgElement = “”
roundResultMsg = “”
};
I think the issue is with the first line itself as the code does not seem to pass it. The error I am receiving is - Your resetGame
function should set the playerScore
to 0
.
you are not using the innerText
property on above variables. if you add innerText with these variables your challenge will pass.
AnshSA
July 16, 2024, 10:59am
6
hasanzaib1389:
innerText
Tried that, but does not work. Same error again
function resetGame() {
playerScore = 0;
computerScore = 0;
computerScoreSpanElement.innerText = “0”;
playerScoreSpanElement.innerText = “0”;
resetGameBtn.style.display = “none”;
optionsContainer.style.display = “block”;
roundResultsMsg = “”;
winnerMsgElement = “”;
};
this time you changed that lines again, assign the palyer and computer scores again.
and with above variable you need innerText also.
AnshSA
July 16, 2024, 11:04am
8
@hasanzaib1389 - Thank you. I tried your suggestion and it worked!
function resetGame() {
playerScore = 0;
computerScore = 0;
computerScoreSpanElement.innerText = “0”;
playerScoreSpanElement.innerText = “0”;
resetGameBtn.style.display = “none”;
optionsContainer.style.display = “block”;
roundResultsMsg.innerText = “”;
winnerMsgElement.innerText = “”;
};
that is great. your welcome. but please do not post the solution code.