Tell us what’s happening: Now, set the innerText property of monsterName to be the name property of the current monster. Do the same for monsterHealthText and the health property.
I can’t figure this step out. I have been at it for a few days now. Please help.
The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.
You will need to take an additional step here so the code you wrote presents in an easy to read format.
Please copy/paste all the editor code showing in the challenge from where you just linked.
Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Challenge Information:
Learn Basic JavaScript by Building a Role Playing Game - Step 118
I think perhaps my last hint didn’t come across as I had hoped. This has nothing to do with const or let. Look at all the code already in the goFight function. Do you see where you saved of the monster’s health in a variable near the beginning of the function? The tests want you to use that variable to set the innerText for the monster’s health.
Look at the code near the beginning of this function. Didn’t you already save this value to a variable? The tests want you to use the variable to set the innerText.
Let me repeat, the code you originally pasted at the beginning is technically correct. It’s just that you are not assigning innerText in the last line exactly the way the tests want you to. They don’t want you to use monsters[fighting].health. They want you to use the variable that you saved that value to earlier in the function.
So, in the beginning of the code is… monsterHealth = monsters[fighting].health;
They’re not wanting me to use… monsters[fighting].health; as the value since it is already used. Okay I understand that.
Ya, innerText can’t be used by itself. It is a property of an element.
Look at how you set the innerText for the monster’s name:
monsterName.innerText = monsters[fighting].name;
That’s how you would do it for the monster’s health text as well.
Again, the problem is on the right side of the equals sign. You need to use the variable that already contains the monster’s health.
I’ll repeat again, the original code you submitted is technically correct. The only issue is that you need to use the variable that already has the monster’s health instead of using monsters[fighting].health explicitly in the last line. That’s the only change you should make to your original code.