CodeCombat Hunting Party help [SOLVED]


#1
// You can use findNearestEnemy() on your soldiers to get their nearest enemy instead of yours.
while (true) {
    var friends = hero.findFriends();
    // Use for-loop and for each friend:
    for(var f = 0; f < friends.length; f += 1); {
        // If they see an enemy then command to attack.
        var friend = friends[f];
        var enemy = friend.findNearestEnemy();
        if (enemy) {
            hero.command(friend, "attack", enemy);
        }
        // Command to move east by small steps.
         else  {
           
 hero.command (friend, "move", {'x': friend.pos.x + 25,'y': friend.pos.y});
        }
    }
}

Im pretty sure this is the correct code, but my soldiers/archers don’t move when I run it.


#2
while (true) {
    // code
    for(var f = 0; f < friends.length; f += 1); {
        // code
    }
}

Do you see the typing error?


#3

Do I need to change my variable? The while (true) part was already in placed when the level started, and that for loop was replicated from my previous levels which were completed.


#4

this little thing
;
is messing with your program.


#5

OH, I didn’t catch that. Thanks for helping me, I’ve been stuck on that level for so long. My code worked now and I passed the level thank you