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

Tell us what’s happening:

Difficulty to update the indicated values. I’ve been trying to do as said in the topic description but it’s not making any sense =(

Your code so far

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

/* file: styles.css */

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

const playerScoreSpanElement = document.getElementById("player-score");
const computerScoreSpanElement = document.getElementById("computer-score");
const roundResultsMsg = document.getElementById("results-msg");

function showResults(userOption) {
  playerScoreSpanElement.innerText = playerScore++;
  computerScoreSpanElement.innerText = computerScore++;
  roundResultsMsg.innerText = getRoundResults()
};

showResults("Rock");

// 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/136.0.0.0 Safari/537.36

Challenge Information:

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

Can you please explain what’s confusing you in more detail?

I don’t know how should I call for the results and show them on the screen, since I have to use innerText. I’ve tried a lot of different ways like calling the getRoundResults function with different parameters for each line of the code. How do I both increase the score and show the results for what I’ve tried a lot of different things.
my code looks like this rn
playerScoreSpanElement.innerText = playerScore;
computerScoreSpanElement.innerText = computerScore;
roundResultsMsg.innerText = getRoundResults(user0ption)

what does getRoundResults do when it’s called?

I guess it should bring up the round results… it’s really confusing for me sometimes

you can look what the function does, it’s in the editor

it does something that determines the order in which you need to do things for this step

Oh I dont know why i am still getting that error too it doesnt make sense and i have been trying all the solutions but just can’t seem to get what codeCamp wants…tiring

What does getRoundResults() do right after it determines if the player won or the computer won?

it returns the respective message, but I don’t know how to do that… I’ve been trying for two days now. I did this lesson from the beggining. Look how my code is right now, don’t even know if I’m close to get it right.

const playerScoreSpanElement = document.getElementById("player-score");
const computerScoreSpanElement = document.getElementById("computer-score");
const roundResultsMsg = document.getElementById("results-msg");

function showResults(userOption) {
  if (hasPlayerWonTheRound() === true) {
  return playerScoreSpanElement.innerText = `${playerScore++}`;
} else if (hasPlayerWonTheRound() === false) {
  return computerScoreSpanElement.innerText = `${computerScore++}`
  }
  roundResultsMsg.innerText = getRoundResults(userOption)
}
const playerScoreSpanElement = document.getElementById("player-score");
const computerScoreSpanElement = document.getElementById("computer-score");
const roundResultsMsg = document.getElementById("results-msg");

function showResults(userOption) {
  if (hasPlayerWonTheRound() === true) {
  return playerScoreSpanElement.innerText = `${playerScore++}`;
} else if (hasPlayerWonTheRound() === false) {
  return computerScoreSpanElement.innerText = `${computerScore++}`
  }
  roundResultsMsg.innerText = getRoundResults(userOption)
}

Am I even getting closer?

it does something else that you need to consider

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

  if (hasPlayerWonTheRound(userOption, computerResult)) {
    playerScore++;
    return `Player wins! ${userOption} beats ${computerResult}`;
  } else if (computerResult === userOption) {
    return `It's a tie! Both chose ${userOption}`;
  } else {
    computerScore++;
    return `Computer wins! ${computerResult} beats ${userOption}`;
  }
}

what is it doing before returning?

it’s increasing the playerScore, but I’m trying to bring playerScore to the playerScoreSpanElement in every way I can think about and it just doesn’t work… aaaaaa

so if it increses playerScore and computerScore

When you write this, which score goes in playerScoreSpamElement and computerScoreSpanElement? the old or the updated one?

removed by mod
It works !!

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.