Review Algorithmic Thinking by Building a Dice Game - Step 5

Tell us what’s happening:

The task statement is
You’ll need to be able to update your rolls and your round on the page. Create an updateStats function to update the text of those two elements with the appropriate values. Then, call that function when your rollDiceBtn is clicked and the dice are rolled.

Can someone tell how can solve it

Your code so far

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

/* file: styles.css */

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

function updateStats() {
    currentRound.textContent = `Round: ${round}`;
    currentRoundRolls.textContent = `Rolls: ${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/127.0.0.0 Safari/537.36

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 5

Don’t use string literals and don’t update the textContent with any strings. Just output the values in the variables as-is.

Thanks Buddy! Got it Now.

1 Like