this is my code
// You are trapped. Don't move, it'll be painful.
// This function checks if the enemy is in your attack range.
function inAttackRange(enemy) {
var distance = hero.distanceTo(enemy);
// Almost all swords have attack range of 3.
if (distance <= 3) {
return true;
} else {
return false;
}
}
// Attack ogres only when they're within reach.
while (true) {
// Find the nearest enemy and store it in a variable.
var enemy = hero.findNearestEnemy();
// Call inAttackRange(enemy), with the enemy as the argument
// and save the result in the variable canAttack.
inAttackRange();
// If the result stored in canAttack is true, then attack!
if (true) {
hero.attack(enemy);
this is what happens when i try to run it