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

Tell us what’s happening:

hi everyone,
please i’m stuck here , i have try to do it the dumb way i understand and it has logged the result to it’s respective element but i’m not passing it. please any well explained tip will be appreciated.

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) {
  let computerResult = getRoundResults(userOption);

  playerScoreSpanElement.innerHTML += 1;
  roundResultsMsg.innerHTML = `Player wins! ${userOption} beats ${computerResult}`;

  roundResultsMsg.innerHTML = `It's a tie! Both chose ${userOption}`;

  computerScoreSpanElement.innerHTML += 1;
  roundResultsMsg.innerHTML = `Computer wins! ${computerResult} beats ${userOption}`;
};

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

Challenge Information:

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

how you have written, the last line determines the content of the element,
You need to add some conditionals that determine when each statement is added to the page

you are added many extra code . reset your code and update player and computer socre to 0. then update span element of both to 0. lastly update get roundResultsMsg to getRoundResults(userOption), using innerText property.

Your code is incorrect for following reasons:

  1. playerScoreSpanElement.innerHTML += 1; is incorrect because playerScoreSpanElement.innerHTML is a string not number. So when you add 1 to it, the previous value does not add to it, instead it gets concatenated.
    You have to increment the playerScore variable first then assign it to playerScoreSpanElement.innerText. This will be same for computerScoreSpanElement.

  2. You have already written function getRoundResults(userOption) to get the result message. You just have to call this function and assign it to roundResultMsg.innerText to update the message.

okay, thanks so much now i understand better but do i need to make use of f condition statement again?

No, You don’t need to use if condition statement again. It’s already used in getRoundResults() function.

thank you so much bro, more wisdom to sail higher in this field i wish you.