Here’s my code:
function cleaveWhenClose(target) {
    if (hero.distanceTo(target) < 5) {
        if (hero.isReady("cleave")) {
            hero.cleave(target);
        }
    } else {
        hero.attack(target);
    }
}
while (true) {
    var enemy = hero.findNearestEnemy();
    if (enemy) {
        cleaveWhenClose(enemy);
    }
}
 
This is an easy level and I have done it before but I forgot-
@Hydrobolic ? or someone??
My items:
             
            
               
               
               
            
            
           
          
            
            
              It looks like the function’s if and else statements  has mistakes.
Looks closer.
             
            
               
               
              1 Like 
            
            
           
          
            
            
              It doesn’t matter with your items. Look:
The if and else statements do not match! 
             
            
               
               
              1 Like 
            
            
           
          
            
            
              Well, match the if and else statements!
             
            
               
               
               
            
            
           
          
            
            
              
move the else down off the bracket im no expert at javascript but i think this is your error
             
            
               
               
               
            
            
           
          
            
            
              @Vanessa , just indent the “else” by one tab space and youll be good. let me know if you need anything else and if that was the only problem, could you delete the code? otherwise other ppl would easily be able to copy it
             
            
               
               
              1 Like 
            
            
           
          
            
              
                system  
                
                  Closed 
               
              
                  
                    August 18, 2021, 12:13pm
                   
                   
              10 
               
             
            
              This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.