Learn Basic JavaScript by Building a Role Playing Game - Step 125

Tell us what’s happening:

Step 125
Update healthText.innerText and monsterHealthText.innerText to equal health and monsterHealth.

(This is google getting the error asking me to d o what I have done.)

Could the problem be associated with the display of where the blue squares are? The squares that indicate what steps are done.
Is 125 asking for each instance of the items listed?
Tedious. Hours on this, but no payday:( Update healthText.innerText and monsterHealthText.innerText to equal health and monsterHealth

Your code so far

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

/* file: styles.css */

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

function attack() {
  text.innerText = "The " + monsters[fighting].name + " attacks.";
  text.innerText += " You attack it with your " + weapons[currentWeaponIndex].name + ".";
  health -= monsters[fighting].level;
  monsterHealth -= weapons[currentWeaponIndex].power + Math.floor(Math.random() * xp) + 1;
  
}

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

Learn Basic JavaScript by Building a Role Playing Game - Step 125

You don’t seem to have added any new code?

Please post what you have tried.


You should set healthText.innerText to health and monsterHealthText.innerText to monsterHealth. It is two separate lines of code.

someElement.innerText = someValue;
someOtherElement.innerText = someOtherValue;

I’m trying step 125 when the code fails I need to goto several places to edit those, even into the const area and buyHealth, goFight, etc… should I paste all that code?

Hi there!
You didn’t attempt any code as per the challenge instructions.

function goFight() {
update(locations[3]);
monsterHealth = health;
monsterStats.style.display = “block”;
monsterName.innerText = monsters[fighting].name;
monsterHealthText.innerText = monsterHealth;

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.”;
}
}
}

Reset your code and add new code within the attack function.

I used the reset for step-125 yet the function attack still has code:
function attack() {
text.innerText = “The " + monsters[fighting].name + " attacks.”;
text.innerText += " You attack it with your " + weapons[currentWeaponIndex].name + “.”;
health -= monsters[fighting].level;
monsterHealth -= weapons[currentWeaponIndex].power + Math.floor(Math.random() * xp) + 1;

}

Where is the new code? The instructions are asking for.

Instructions for the challenge step is:
Update healthText.innerText and monsterHealthText.innerText to equal health and monsterHealth.

Well, rethinking what I could do, I decided it wouldn’t hurt to try ADDING it to the current step-125 section: function attack. To my surprise, that passes. 3 or so hours of looking for the text when adding it was what was wanted. Sorry about wasting so much of the “Help team”, but thanks to all that replied!

2 Likes