Review Algorithmic Thinking by Building a Dice Game - Step 9

Tell us what’s happening:

I don’t understand the errors i’m getting:
Your updateScore function should add the value of the first parameter to the total score.
Your updateScore function should update the text of the totalScore element.
Your updateScore function should add a new list item to the scoreHistory element.
When updateScore(10, “hi”) is called, your new list element should have the text hi: 10.

I believe i have done what the Step is asking

Your code so far

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

/* file: styles.css */

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

const updateScore = (selectedValue, achieved) => {
  totalScore += parseInt(selectedValue);
  totalScoreText.textContent = totalScore;
  scoreHistory.innerHTML += `<li>${achieved} : ${selectedValue}</li>`;
};

// 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 9

Check your spaces here

Where was this defined?

i just copy and pasted what the step said.

But is this how it should be:

scoreHistory.innerHTML += `<li>${achieved}: ${selectedValue}</li>`;

Because FreeCodeCamp seems to have condensed this project into 18 steps (from over 60) - i’m finding the instructions too brief to understand. So i’ve been following a You Tube video which has the 60+ steps. But unfortunately, that seems to use slightly different variable names.

Is this better:

const updateScore = (selectedValue, achieved) => {
  totalScore += parseInt(selectedValue);
  totalScore.textContent = totalScore;
  scoreHistory.innerHTML += `<li>${achieved}: ${selectedValue}</li>`;
};

I looked up where totalScore is defined and I found this:
const totalScore = document.getElementById(“total-score”);

This is not a number. So how would it add a number to it?
Is there another variable that might represent the score that you can use?

after reading the other forum posts, i’ve landed on this:

const updateScore = (selectedValue, achieved) => {
  total += selectedValue;
  totalScore.textContent = total;
  scoreHistory.innerHTML += `<li>${achieved}: ${selectedValue}</li>`;
};

but still getting these errors:
Your updateScore function should add the value of the first parameter to the total score.
Your updateScore function should update the text of the totalScore element.
When updateScore(10, “hi”) is called, your new list element should have the text hi: 10.

is there any other variable defined that might be the total score?

can you fix the spacing to be exactly as requested?

I would not copy YouTube. This project the entire point is trying to figure out steps and asking questions if you need.

i don’t “copy” Youtube - i pause the video to read old (longer, more detailed) step, complete the step myself, then unpause the video to confirm i have done it correctly.

As i stated above, this lesson has been changed from 60+ steps, into 18 steps. And it’s impossible to complete the project by only reading the 18 steps, they are too brief and don’t give anywhere near enough information. Even when i’ve asked for help on the forums, the people responding don’t seem know what to do either. So there is definitely something wrong with this lesson.

I’d put a complaint/feedback in, but as it says JavaScript Algorithms and Data Structures is “currently in beta”, i assume that they are still working on this lesson and are in the processes of fixing the issues i’m talking about.

The point of this project is for you to try to develop the logic instead of being lead through it step by step. A walkthrough video defeats the purpose. A downside of too many steps in the project based approach is that you never have to stop and think up approaches to solve anything so these more open ended projects were added so you have a middle ground before the certification projects.

if you’re still stuck let us know. I’m trying to give you feedback to help you move forward…

you either can’t understand what i wrote or you just aren’t reading it properly.

i’m not being “led” through anything. The video merely gives me access to the longer steps. Like i said, i pause the video before the person in video does anything, so i’m not copying what they do. I’m doing it myself.

This is 21st lesson in JavaScript Algorithms and Data Structures - the other 20 i have completed. By making this lesson only 18 steps, i believe they have made it too hard. And i don’t believe anyone at the same level as me would be able to complete it.

I understand, I just don’t agree that it’s a good idea. Working through developing a plan is the point of these Steps.

No other variable defined with name ‘totalScore’, but still getting errors as:

Your updateScore function should add the value of the first parameter to the total score.
Your updateScore function should update the text of the totalScore element.

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

Thanks for the information, I found the answer, the algorithm is expecting score variable to add the value. Now it is getting pass,

mod edit: code removed

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

1 Like

Yup, I think the fact that they condensed several steps and erased explanation of what was requested ended up in confusing new steps. Try iterating within the let variables, maybe total is not what is needed.