Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Agrippa defense A code not working


hi there,

I´m new to coding and i wanted to learn coding with this game.
I have made alot of progress i think, but i cannot figure out why this piece of code is not working.
Plz have a look at it and maybe one of you guys can help me out.

hero.enemyInRange = function(enemy) {
    // Return true if the enemy is less than 5 units away.
if (enemy) {
    hero.distanceTo(enemy) < 5;    
      return false;  

hero.cleaveOrAttack = function(enemy) {
    if (hero.isReady("cleave")) {
    } else {

while(true) {
    var enemy = hero.findNearestEnemy();
    if(enemy) {
        // Check the distance of the enemy by calling enemyInRange.
        if (hero.enemyInRange(enemy)) {


We would be happy to help, but for readability could you repost your code using the code format (the button in the post editor that looks like this: </> next to the quotation button)


ok nvm,

I fixed my code, it was that i needed a bit more health to survive the lenght of the battle.
Thank you to any1 that looked at my code, though.