Review Algorithmic Thinking by Building a Dice Game - Step 5

Tell us what’s happening:

I do not seem to understand the correct value that I am update the element to

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

function updateStats(rolls, round) {
  const currentRound = document.getElementById("current-round");
  const currentRoundRolls = document.getElementById("current-round-rolls");
}

rollDiceBtn.addEventListener("click", () => {
  if (rolls === 3) {
    alert("You have made three rolls this round. Please select a score.");
  } else {
    rolls++;
    rollDice();
    updateStats();
  }
});

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

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 5

1 Like

Hello,
first, you do not have to pass the rolls and round variables to your function updateStats, they are defined outside of it at the top of the script.
You also do not have to reselect the currentRound and currentRoundRolls variables as you already did that at the top of the script.
To change the text of a selected element, you can use the textContent property, here is an example, I have a div element, I am going to select it and then add the text Hello World to it

const target = document.querySelector("div");
const myText = "Hello World"; // this is the text I want to add to my div

target.textContent = myText;
```
1 Like

Thank you for the help, but my issue is that if I am to update the text of rolls and round , what is the correct value that I am to update it to.

Please I need some clarity

function updateStats() {

currentRoundRolls.textContent = rolls;

}

you should update currentRound with the round variable and currentRoundRolls with rolls variable

2 Likes

Thank you so much for the clarification

1 Like