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

Tell us what’s happening:

I don’t understand what the issue is. My current code does not have the winnerMsgElement updated but when I do, the console will tell me that there is a typerror or that it is not defined.

In addition, it seems that whenever I try to update the winnerMsgElement, my other code becomes nullified and I regress in steps. – going from 2/3 steps completed to 0/3.

Can someone explain what the issue is?

Your code so far

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

/* file: styles.css */

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

const playerScoreSpanElement = document.getElementById("player-score");
const computerScoreSpanElement = document.getElementById("computer-score");
const roundResultsMsg = document.getElementById("results-msg");
const winnerMsgElement = document.getElementById("winner-msg");
const optionsContainer = document.querySelector(".options-container");
const resetGameBtn = document.getElementById("reset-game-btn");

function showResults(userOption) {
  roundResultsMsg.innerText = getRoundResults(userOption);
  computerScoreSpanElement.innerText = computerScore;
  playerScoreSpanElement.innerText = playerScore;
if(playerScore || computerScore === 3) 
{optionsContainer.style.display = "none";
resetGameBtn.style.display = "block"}

};


// 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 5

Hi.

Have you done the second part of this instruction?

“If either has reached three points, you should display a message indicating the winner.”

Question for you:
How did you update your winnnerMsgElement? Did you update winnerMsgElement.innerText, or just winnnerMsgElement?

This statement evaluates to true as soon as playerScore is not falsy. In other words, it will be true whenever playerScore is not zero, regardless of whether computerScore is equal to 3.

Hi, I actually tried both with .innerText and without. Neither worked but I’ll update my if statement and go from there. Thanks!

Hi,

yes that’s the part that kept failing each time I tried

Let us know if you get stuck.

Can you tell me where in your code there is a message that displays to the winner that the Player has won the game or if the computer has won the game if that is the case?