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

Tell us what’s happening:

What am I missing?**

Your getRoundResults function should return the correct message based on who wins the round. If no one wins, the message should say it’s a tie.

Your code so far

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

/* file: styles.css */

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

function getRoundResults(userOption) {
  const computerResult = getRandomComputerResult();
if (userOption === computerResult) {
   return "It's a tie! Both players chose ${userOption}"
  } else if (hasPlayerWonTheRound(userOption, computerResult)) { 
    playerScore++
  return "Player wins! ${userOption} beats ${computerResult}"
 } else {
   computerScore++
   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 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36

Challenge Information:

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

1 Like

You have used double quotes for the template literals [ when returning the message] instead of the backticks (`).

The message when it is a tie is also not correct.

1 Like

When I change from " to ’ the text greys out on my screen. I posted the new code in a new string.

function getRoundResults(userOption) {
const computerResult = getRandomComputerResult();
if (userOption === computerResult) {
return ‘It’s a tie! Both chose ${userOption}’;
} else if (hasPlayerWonTheRound(userOption, computerResult)) {
playerScore++
return ‘Player wins! ${userOption} beats ${computerResult}’;
} else {
computerScore++
return ‘Computer wins! ${computerResult} beats ${userOption}’;
}
}

You have used a single quote instead of the backtick.(`).

Backticks (`) are not single quotes (').

The backtick should usually be on the left of the 1 key on the qwerty keyboard.
Alternatively you can check this to find the backtick on your keyboard.

1 Like