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

Tell us what’s happening:

I am trying to figure out why my second if statement won’t correctly display the message. I have tried doing a linear but fell back on that idea.

Posting code below.

Your code so far

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

/* file: styles.css */

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

function getRoundResults(userOption) {
  const computerResult = getRandomComputerResult();
  if (playerScore + 1) {
    return "Player wins! " +  userOption + " beats " + computerResult;
  }
  if (computerResult == userOption) {
    return "It's a tie! Both chose " + userOption;

  }
  if (computerScore + 1) {
    return "Computer wins! " + computerResult + " beats " + userOption;
  }
}

console.log(getRoundResults("Rock"));
console.log("Player Score: ", playerScore, "Computer Score: ", computerScore);

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36

Challenge Information:

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

Can you describe what determines if one of the players has won the game?

if player wins then their “playerScore” goes up by +1 and then returns the string with output named in return string.

and if both results equal the same then is should return that string also.

then for the third if computerScore + 1 then it returns that string

I am assuming you are asking if not sorry for wrong reply.

So, in the game, a player clicks rock, paper, or scissors, right? And after that, the winner’s score changes. True.

But how do you know if the player has won the round compared to the computer’s randomly generated choice?

More specifically, how does this condition tell you if the player or computer has won the round?

So you are saying, I need to define the fact or variable to make sure it counts as player winning in a section. So when that triggers it activates to playerScore. Let me try a variable and see if it works.

@fcc4b6d10c4-b540-4e2

I was able to define the variable in a section above code, and was able to clarify it with the
“hasPlayerWonTheRound” above since that is what is the initiate of the game. Then will be the main person to call with the computer and player respectively.

Thank you for making me read and look and take a break from this.

Congrats! So glad you were able to work it out.

Happy Coding