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

Tell us what’s happening:

Why i am getting this error You should add the result of Math.floor(Math.random() * xp) + 1 to the result of weapons[currentWeaponIndex].power.

Your code so far

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

/* file: styles.css */

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

  monsterHealth -= weapons[currentWeaponIndex].power + xp;
  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/127.0.0.0 Safari/537.36

Challenge Information:

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

hi there!

you only need the Addition oparetor to add the Math.floor(Math.random() * xp) + 1;.
you added Addition assignment opretor.

1 Like