[Solved] Learn Basic Javascript by Building a Role Playing Game - Step 76

Im not really sure what they are asking me to do here:

" After your assignment lines, assign the innerText property of goldText to be the variable gold . Use the same pattern to update healthText with the health variable."

there is an example given "

let value = 100;
const total = document.querySelector('#total');
total.innerText = value;

i’m probably just over thinking it, but not sure where to start. Help Please!

All good, I figured it out.

I have updated your post to include the challenge link.

It is important to always include this link so people can help you :+1:

As for this problem, the line in the example you want to pay attention to is this one

It is showing you how to use the innerText property.
But also how to update an element’s innerText by assigning a value to it.

Remember that the way assignment works is that whatever is on the right hand side of the assignment operator gets assigned to whatever is on the left.

myExampleElement.innerText = "some value I am assigning to it to update its text"

The challenge wants you to update the goldText 's innerText by assigning it the value of gold

Same thing for the healthText and health variable

hope that helps

5 Likes

Glad you were able to figure it out :+1:

2 Likes

I love your helpful responses Miss Wilkins. Appreciated the time taken, thank you!

2 Likes

I also am struggling with this step.
below is my code so far.

function buyHealth() {
gold -= 10;
health += 10;
healthText.innerText = health;
goldText.innertext = gold;
}

1 Like

function buyHealth() {
gold -= 10;
health += 10;
goldText.innerText = gold;
healthText.innerText = health;
}

2 Likes

Thank You!! This helped me a lot!

innertext = gold
innerText = gold
just a spelling error, friend

“After your assignment lines,” really means…

Staying inside the same buyHealth( ) function we are building; we are going to assign the innerText property of goldText to be the variable gold …and then “Use the same pattern to update healthText with the health variable.”