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

Tell us what’s happening:

It keeps telling me my code should return a string, but for every if function I am return a string, so I don’t see the issue…

Your code so far

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

/* file: styles.css */

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

function getRoundResults(userOption) {
  const computerResult = getRandomComputerResult();
  if (hasPlayerWonTheRound(player, computer)){
    playerScore += 1;
    return console.log(`"Player wins! ${userOption} beats ${computerResult}"`)
  }
  else if (hasPlayerWonTheRound(player, computer) ==  false){
    computerScore += 1;
    return console.log(`"Computer wins! ${computerResult} beats ${userOption}"`)
  }
  else if(computerResult == userOption){
    return console.log(`"It's a tie! Both chose ${userOption}"`)
  }
}
return 
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/125.0.0.0 Safari/537.36

Challenge Information:

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

You are returning a console.log() of a string, not a string. You don’t need the console.log().

1 Like

Thankyou! I have console.log removed, but It’s still not passing, is my code just fundementally wrong? I also tried removing the “” inside of each `` and added a “;” to the end of each return, any other suggestions on what I could try?

post your latest code please

function getRoundResults(userOption) {
  const computerResult = getRandomComputerResult();
  if (hasPlayerWonTheRound(player, computer)){
    playerScore += 1;
    return (`"Player wins! ${userOption} beats ${computerResult}"`);
  }
  else if (hasPlayerWonTheRound(player, computer) == false){
    computerScore += 1;
    return (`"Computer wins! ${computerResult} beats ${userOption}"`);
  }
  else if(computerResult == userOption){
    return (`"It's a tie! Both chose ${userOption}"`);
  }
}
console.log(getRoundResults("Rock"));
console.log("Player Score: ", playerScore, "Computer Score: ", computerScore);

For some reason, the `` surrounding the strings aren’t showing up in the comment, but are in the code

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

I don’t see this in your code, this is a necessary change

the other issue, player and computer are not defined, you should be getting an error in the console
you need to use the local variables you have for the player and computer choice