You should add to the weapons[currentWeapon].power value

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

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

Hey @Great01 ,
Welocme to the community.
It’s a simple mistake your code is right but you just have to change the order .weapons[currentWeapon].power should be first than add (Math.floor(Math.random() * xp) + 1) to it.
Happy coding

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

still didn’t work

You should add the result of Math.floor(Math.random() * xp) + 1 to the result of weapons[currentWeapon].power .

it worked, i just removed the brackets from the (Math.floor(Math.random() * xp) + 1)

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