Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

The Agrippa Defense java script. MAJOR HELP😐

I have tried to beat this level for many days now and just can’t seem to do it. It says my line of code regarding “var distance = hero.distanceTo(target);” is wrong. Any ideas on how to do it?
(i do not know how to format my code so sorry about that I will try to learn in the future.)

while(true) {
    var enemy = hero.findNearestEnemy();
    if(enemy) {
        // Find the distance to the enemy with distanceTo.
        var distance = hero.distanceTo(target);
        // If the distance is less than 5 meters...
        if (distance<5) {
            
        }
            // ... if "cleave" is ready, cleave!
            if (enemy) {
                var ready = hero.isReady("cleave");
                hero.cleave(enemy);
            }
            // ... else, just attack.
            else {
                hero.attack(enemy);
            }
    }
}

Hi,
Here’s how you format your code:


I did it for you this time.
The problem is in that line. What is target? Where is it defined? Have you checked if it exists?
Danny