Tell us what’s happening:
Hello. There are some problems in my code because it doesn’t pass. Please help me with them. Here the data from the right developer console:// running tests
- Your showResults function should update the roundResultsMsg with the result of the round.
- Your showResults function should update the computerScoreSpanElement to show the updated score of the computer.
- Your showResults function should update the playerScoreSpanElement to show the updated score of the player.
// tests completed
// console output
[ReferenceErr
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");
let playerScore = 0;
let computerScore = 0;
function getRoundResults(userOption) {
const choices = ["Rock", "Paper", "Scissors"];
const computerOption = choices[Math.floor(Math.random() * 3)];
if (userOption === computerOption) {
return "It's a tie!";
}
if (
(userOption === "Rock" && computerOption === "Scissors") ||
(userOption === "Paper" && computerOption === "Rock") ||
(userOption === "Scissors" && computerOption === "Paper")
) {
playerScore++;
return `You win! ${userOption} beats ${computerOption}.`;
} else {
computerScore++;
return `You lose! ${computerOption} beats ${userOption}.`;
}
}
function showResults(userOption) {
const roundResult = getRoundResults(userOption);
roundResultsMsg.innerText = roundResult;
playerScoreSpanElement.innerText = playerScore;
computerScoreSpanElement.innerText = computerScore;
}
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/128.0.0.0 Safari/537.36 OPR/114.0.0.0
Challenge Information:
Review DOM Manipulation by Building a Rock, Paper, Scissors Game - Step 4