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

Tell us what’s happening:

I can’t seem to figure out why I can’t pass step 4, I’ve checked that my score variables are working in console.log, and I double checked the innerText syntax.

The instructions:

Step 4

Now it is time to update the scores and the round results message.

Complete the showResults function. The playerScoreSpanElement and computerScoreSpanElement should be updated to show the updated scores of the player and computer.

The roundResultsMsg should also be updated with the result of the round.

Tips

  • Remember that you learned how to work with the innerText property to update the text content of an element.
  • You can use the getRoundResults function to get the result of the round.

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(userOption);
};

showResults("Scissors");

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:125.0) Gecko/20100101 Firefox/125.0

Challenge Information:

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

3 Likes

Hi @amber.n.weinberg !

Welcome to the forum!

You are super close.
But order does matter here in how you list these statements

Right now you are saying set the player score span and computer score span first.
But you haven’t gotten any results yet.
So the scores will always be 0 because you haven’t calculated the results yet.

But if you fix the order, then you will better be able to display the scores from that round.
Instead of their default values

once you fix that, then the test will pass

hope that helps

9 Likes

oh my goodness what a duh! Thank you! Thank you! <3

4 Likes

I tried it, but I seem to be getting an error.

Never mind. I figured it out.

Me too!

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

What did you do to fix this please :slight_smile:

looks like you’re missing an ‘s’ in roundResultsMsg

I had exactly the same problem! :laughing:

This was incredibly helpful. Thank you!