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

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

  1. Your showResults function should update the roundResultsMsg with the result of the round.
  2. Your showResults function should update the computerScoreSpanElement to show the updated score of the computer.
  3. 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

Hi! Your code works on my side and it seems correct. I think this is the correct solution for this step of this challenge. Can you maybe disable all extensions and try again?

1 Like

Thank you very much. My browser doesn’t want to be friends with this project in any way. It constantly has to be updated so that it allows the next code to pass.

1 Like

Yes yes I understand. I had the same problems with these challenges also. I ended up changing browsers :woman_shrugging:t2:

1 Like

Somehow, thanks to your help, I managed to bring this project to mind like all the previous ones. What have I not done with my browser so that it stops butting heads with the project I am going through. Somehow I managed to reconcile them and here is the result: the test is passed.


1 Like