Hi I’m having issues with this problem. I checked the other forums post and solutions there which is what I usual do and that helps but im not sure why its not working.
rollDiceBtn.addEventListener(“click”, () => {
if (rolls === 3) {
alert(“You have made three rolls this round. Please select a score.”);
} else {
rolls++;
rollDice();
}
updateStats(
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
function updateStats() {
currentRoundRolls.textContent = rolls;
currentRound.textContent = rounds;
}
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
/* file: styles.css */
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
you have this in the wrong location. Right now you are calling the function anytime someone clicks the button, even if the rolls are equal to 3. Does that seem correct logically? (or even compare that to what they wanted to see if it is correct)
The other problem is the code in updateStats.
It is referencing variables that do not exist?
bro none of this makes sense I tried chat gtp I have look at other forums post and I got nothing this makes zero sense what the hell Im doing wrong or what im supposed to be doing here.
i have given 2 pieces of guidance/hints.
Which one do you need help understanding?
You will have to attempt to ask a proper question to get a response.
Don’t use chatgpt, you don’t know if it was trained on the correct data to solve this problem, and you nor chatgpt are able to evaluate if it’s answers are correct.
Read the advice above and take it one problem at a time.
The instructions say:
call that function when your rollDiceBtn is clicked and the dice are rolled.
So you should call the function when the dice are rolled. Right after the dice are rolled. Can you adjust where you call the function?
I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
that these are the lines that needs to be changed with the textcontext property. I believe that’s the correct term. which needs to equal rolls and rounds which I did
You don’t need to change these lines but you need to understand the point I made already:
Compare the code you wrote in updateStats to the existing variables defined at the top of the program. You are trying to reference a variable that doesn’t exist (or has not been declared). This is the mistake you need to fix. The hint is trying to also tell you this.