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

Tell us what’s happening:

Hello. I am just looking to see if anyone else may have an issue with this. I have no issues running this code from VSCode. Everything runs correctly, however the code does not work on the site.

I continuously receive this issues:

  1. Your getRoundResults should return a string
  2. 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.

I am receiving the error on the site. VSCode shows no errors. Any ideas?

Your code so far

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

/* file: styles.css */

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

let computerScore = 0;
let playerScore = 0;

function getRoundResults(userOption) {
  const computerResult = getRandomComputerResult();
  if(hasPlayerWonTheRound(userOption, computerResult)){
    playerScore++;
    return `Player Wins! ${userOption} beats ${computerResult}`
  } else if(userOption === computerResult) {
    return `It's a tie! Both chose ${userOption}`
  } 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 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0

Challenge Information:

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

Hi @derekbwhite80 !

Welcome to the forum!

When I copy your code exactly, I see this error in the console

SyntaxError: unknown: Identifier 'computerScore' has already been declared. (20:4)

  18 | // User Editable Region
  19 |
> 20 | let computerScore = 0;
     |     ^
  21 | let playerScore = 0;
  22 |
  23 | function getRoundResults(userOption) {

When I resolve that error and remove the duplicate variable declaration, it passes for me

hope that helps

Thanks. After I posted this I ended up restarting the browser and everything worked just fine. Not sure why it didn’t work previously.