It keeps saying “RAN OUT OF TIME”. I have tried multiple times. I am coding with JavaScript. I
This is my code:
while(true) {
// Check the distance to the nearest enemy.
var nearestEnemy = hero.findNearestEnemy();
var distance = hero.distanceTo(nearestEnemy);
// If it comes closer than 10 meters, cleave it!
if (distance < 10) {
hero.cleave();
}
// Else, attack the "Chest" by name.
else{
hero.attack("Chest");
hero.attack("Chest");
}
}
i think mabey only attack the chest once
Try:
while(true) {
// Check the distance to the nearest enemy.
var nearestEnemy = hero.findNearestEnemy();
var distance = hero.distanceTo(nearestEnemy);
// If it comes closer than 10 meters, cleave it!
if (nearestEnemy && distance < 10) {
hero.cleave(nearestEnemy);
}
// Else, attack the "Chest" by name.
else {
hero.attack("Chest");
}
}
please don’t give full answers sooo can you deleat this commant
Doesn’t Work. Still the same Error
Doesn’t Work. Same Error.
Can you post your equipment please?
and use this pet:

and debug your code 
the duck works like this:
you understand what you need to do in the code.
you explain the duck what you need to do
and you look at the code at the same time.
and then you will see the bug!
will this work?
while(true) {
// Check the distance to the nearest enemy.
var nearestEnemy = hero.findNearestEnemy();
var distance = hero.distanceTo(nearestEnemy);
// If it comes closer than 10 meters, cleave it!
if (distance < 6) {
hero.cleave();
}
// Else, attack the "Chest" by name.
else{
hero.attack("Chest");
}
}
@Codingisawesome can you post a screenshot of the level and your gear please?
I’ve tried your code with my weakest gear and Tharin and it seems to work fine for me:
Doesn’t Work. I tried with smaller numbers too in the distance.
I will try with Tharin and will get back to you.
Hi. It with works with Tharin! Thank you!
Thank you everyone for helping!