Review Algorithmic Thinking by Building a Dice Game - Step 6

Tell us what’s happening:

I have no idea what is the problem. The only thing that could be possible from my perspective are incorrect methods used on the array, but I couldn’t find any replacements for them on the web.

Your code so far

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

/* file: styles.css */

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

const updateRadioOption = (index, score) => {
  scoreInputs[index].disabled = false;
  scoreInputs[index].value = score;
  scoreSpans[index] = `, score = ${score}`;
}

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) 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 6

scoreSpans[index] is a span element. So to set its text to the given string you should use .textContent

1 Like

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

my bad, I just new here, I did not know. I should not give the answer next time

1 Like

Two questions on this:

  1. Would using .innerHTML work as well as .textContent? I still get confused on when to use one or another
  2. To set it’s text, should we use the += or simply the = operator? I’m also still confused when to append and when to replace/attribute in these cases

Thanks!

The word innerHTML should tell you that it is different. It allows you to actually create html elements and nest them into the element you are modifying. While text content will treat what you are adding in as a single node and it will add break elements if your content has newline characters.

As for which assignment operator to use. This depends on your objective. If you want to erase what is there and write over it, use equal sign. Otherwise use += to add to the existing content.

1 Like