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

Tell us what’s happening:

I don’t understand why .innerText is used here instead of .innerHTML. Isn’t the point of .innerHTML to make words show up without showing all the code around the elements in my HTML file? This would cause the results message to display with the surrounding code right?

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) {
  roundResultsMsg.innerText = getRoundResults(userOption);
  playerScoreSpanElement.innerText = playerScore;
  computerScoreSpanElement.innerText = computerScore;
};

showResults("Rock");

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36

Challenge Information:

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

Hi @jeff-upgraded

.innerHTML is for adding html elements.
.innerText is for adding text content to those html elements.

Happy coding

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.