Step 75 in Learn Basic JavaScript by Building a Role Playing Game

I am not able to complete this step. Will anyone of you be able to help me complete this step?

Step 75
Now that you are updating the gold and health variables, you need to display those new values on the game screen.
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.
Here is an example:
```
let value = 100;
const total = document.querySelector('#total');
total.innerText = value;
```
You can test this by clicking your "Go to store" button, followed by your "Buy Health" button.
Note: Your answer should only be two lines of code.

My code:

function buyHealth() {
  gold -= 10;
  health += 10;
    document.querySelector("#gold").innerText = gold;
  document.querySelector("#health").innerText = health;
}

share this step/exercise url too, happy coding :slight_smile:

I updated your post to include the challenge link.
Please make sure to include this in the future, when asking for help :+1:

Your issue is here

Take closer look to lines 14 and 15 of this project

const healthText = document.querySelector("#healthText");
const goldText = document.querySelector("#goldText");

you already declared healthText and goldText variables.
You should use those in your answer.

The goal is to update the gold text and health text.

Once you fix that, then the test will pass

thank you for your sollution, i am getting pass this step

Hey vileshBandekar how did you solve this step??

  document.querySelector("#goldText").innerText = gold;
  document.querySelector("#healthText").innerText = health;

change id’s

1 Like