Battle JavaScript

Hi,

Just wanted to know if anyone could help me in figuring out how to check if the health var is below zero så that it displays, “you killed the monster” when reaches below 0 and not the next time you press attack

https://js.do/KristianFriis/battle

All pointers are welcome though :blush:

In your dealDamage function

health = health - weapon.Damage;

I think this is where you set the health of your opponent, so you can just add an if statement under it to check if the health goes below 0.

Thank you shimphilip :grinning: that solved it :blush: