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

Hi! This is my first time making a post here. :sweat_smile:
But I would like to have some help on what I am doing wrong. :worried:

function getRoundResults(userOption) {
  const computerResult = getRandomComputerResult();
  if (hasPlayerWonTheRound) {
    return "Player wins! " +  userOption + " beats " + computerResult;
  }
  if (computerScore == playerScore) {
    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);

Hi. Welcome to the forum.

Have a look at the condition to your first if statement. What are you trying to do there ? Look at what the hasPlayerWonThe Round function does. How can you use the result from the function in your condition?

You also need to update the playerScore - see the variable for this at the top of the code. How do you achieve this in your execution statement?

In your 2nd if statement condition, why are you comparing the 2 variables (which presently have a value of 0)? Does that represent the result of the game? What represents the player’s score in the game and the computer’s score that you can use instead?

On the final one, if your first 2 statements have conditions for if the player wins or a tie, the final one can just be an else statement without a condition. Again you need to update the computerScore variable with the result of the game as well.

I figured it out. Thank you so much!!! :grinning_face_with_smiling_eyes: :grinning_face_with_smiling_eyes:

1 Like