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

Tell us what’s happening:

function getRoundResults(userOption) {
const computerResult = getRandomComputerResult();

if (userOption === computerResult) {
return It's a tie! Both chose ${userOption}.;
}

if (hasPlayerWonTheRound(userOption, computerResult)) {
playerScore += 1;
return Player wins! ${userOption} beats ${computerResult}.;
} else {
computerScore += 1;
return Computer wins! ${computerResult} beats ${userOption}.;
}
}
can somebody tell me where the probleem is?

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 chose ${userOption}.`;
  } 
  
  if (hasPlayerWonTheRound(userOption, computerResult)) {
    playerScore += 1;
    return `Player wins! ${userOption} beats ${computerResult}.`;
  } else {
    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 (Macintosh; Intel Mac OS X 10_15_7) 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

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

Hi Jermemy

This is the question. My code if here below. I coud’t find wat the mistake is. can you please tell me where the mistake is in my code?

Now it is time to get the results of the round. Complete the getRoundResults function.

If the player wins the round, update the playerScore by 1 and return the message "Player wins! [player's choice] beats [computer's choice]".

If the computer and player choose the same option, return the message "It's a tie! Both chose [player's choice]".

If the computer wins the round, update the computerScore by 1 and return the message "Computer wins! [computer's choice] beats [player's choice]".

[computer's choice] should be replaced with computerResult while [player's choice] should be replaced with the userOption.

Tips

  • Remember you can use the hasPlayerWonTheRound function to check if the player wins the round.
  • You can use template literals or regular string concatenation to build the message.

MY code is hier below

function getRoundResults(userOption) {
const computerResult = getRandomComputerResult();

if (userOption === computerResult) {
return It's a tie! Both chose ${userOption}.;
}

if (hasPlayerWonTheRound(userOption, computerResult)) {
playerScore += 1;
return Player wins! ${userOption} beats ${computerResult}.;
} else {
computerScore += 1;
return Computer wins! ${computerResult} beats ${userOption}.;
}
}

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

i coud’t find where the mistake is ?

I don’t need you to copy-paste the instructions. I need to know what about the code you wrote isn’t making sense to you beyond the fact that it isn’t passing.

I found it by my self, it just i had to remove the dots at the end of the messages