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

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

The code you posted is passing for me.

monsterHealth -= weapons[currentWeaponIndex].power + Math.floor(Math.random() * xp) + 1;

Try copying it, reset and paste it back in. Now submit it again. Do not make any other changes.


If that doesn’t work, try in a different browser or with all extensions disabled.

OK, Chrome worked with the same line of code. Firefox extensions off, and Chrome extensions off.
I prefer Firefox browser and will ‘limp’ along as I can.
Thanks for kicking me over to Chrome, doh!

Try updating Firefox. The code was passing for me in both browsers.

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