Tell us what’s happening:
I fail this step with message saying I need to use an already created monsterHealth from the goFight function, if I remember right.
Below is the code that is failing. The funny thing is this code is exactly what is mentioned in the console
monsterHealth -= weapons[currentWeaponIndex].power + Math.floor(Math.random() * xp) + 1;
Your code so far
function attack() {
text.innerText = “The " + monsters[fighting].name + " attacks.”;
text.innerText += " You attack it with your " + weaponsmonsterHealth + weapons[currentWeaponIndex].power;
monsterHealth -= weapons[currentWeaponIndex].power + Math.floor(Math.random() * xp) + 1;
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
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; rv:127.0) Gecko/20100101 Firefox/127.0
Challenge Information:
Learn Basic JavaScript by Building a Role Playing Game - Step 124