freeCodeCamp.org

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

}
}`

Step 80

Inside the else statement, set text.innerText to equal You do not have enough gold to buy health..

I do not understand the question…

hello! @Steady_Barker

Could u add some details in ur own words, like… ur code and the error message ur getting?

I do not know how to start answering the question.

Hello! @Steady_Barker

We are asked to provide a task if the “else” condition is met.

Eg:

if (this) {
do that
}
else {
do this
}

We have to provide the given text inside the else statement

Happy Coding :grinning:

function buyHealth() { if (gold >= 10) { gold -= 10; health += 10; goldText.innerText = gold; healthText.innerText = health; } else { text.innerText = "You do not have enough gold to buy health"; } }
My code above receives the response:
" Your buyHealth function should set text.innerText to equal You do not have enough gold to buy health..

else {
set text.innerText = to the given text in the challenge
}
In this way, the player would know that he/she is not having enough gold to buy health.

You’ve got this!

Are you saying my code is correct?

Oh! You’re almost there!

You are missing a period after health.

Many thanks. I cannot tell you how long I have been puzzling over this!!

1 Like

Yes! it is correct :tada:

1 Like

That’s fine, A :bulb: whenever we are encountering an error in a challenge just check once for any typo in the required text.

Happy Coding :grinning:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.