Hello, Welcome to the forum. Please explain what problems you are having in more detail.
While there are a few things that can clean up, your code does run and complete the level when I run it even with the basic armor. So I’ll need more details on what you are seeing.
Below are some cleanup suggestions for your code.
Since you already have the
var nearestEnemy = hero.findNearestEnemy(); you don’t need to have the other two lines that find the same value
var Enemy = hero.findNearestEnemy();. Also, since your distance is based on the
nearestEnemy value, you don’t want to grab another value (Enemy) just before you attack. The ‘if’ check ensures the conditions meet the criteria to perform the next task. By grabbing another value after the check, the ‘if’ check becomes pointless.