Review DOM Manipulation by Building a Rock, Paper, Scissors Game - Step 6

Tell us what’s happening:

Why is my code not passing? I have an error saying reset Game function should set playerScore to 0

Your code so far

<!-- file: index.html -->

/* file: script.js */
// User Editable Region

function resetGame() {
  playerScore = 0;
  computerScore = 0;
  computerScoreSpanElement = "0";
  playerScoreSpanElement = "0";
  resetGameBtn.style.display = "none";
  optionsContainer.style.display = "block";
  winnerMsgElement.innerText = "";
  roundResultsMsg.innerText = "";
};


// User Editable Region
/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36

Challenge Information:

Review DOM Manipulation by Building a Rock, Paper, Scissors Game - Step 6

Hi there and welcome to our community!

The error message may be a little misleading, but the issue is that you are trying to reassign values directly to a read-only variable here. As these are references to HTML elements, you can use the innerText method to change their content. If you fix these two lines, your code should pass:

1 Like

Amazing Thank you!

This worked

2 Likes

function resetGame() {
// Reset scores
playerScore = 0;
computerScore = 0;

// Update the score display elements
playerScoreSpanElement.innerText = playerScore;
computerScoreSpanElement.innerText = computerScore;

// Hide the reset button and show options
resetGameBtn.style.display = “none”;
optionsContainer.style.display = “block”;

// Clear the winner and results messages
winnerMsgElement.innerText = “”;
roundResultsMsg.innerText = “”;
}

@Zen.okiki
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.