Codecombat Backwoods Forest "Friend and Foe" *Need Help*

So when I input this code, the Peasants go to get the sword and go to the left side of the map, and the Peons stay where they are. Here is my code:

// Peasants and peons are gathering in the forest.
// Command the peasants to battle and the peons to go away!

while(true) {
    var friend = hero.findNearestFriend();
    if(friend) {
        hero.say("To battle, " + friend.id + "!");
    }
    // Now find the nearest enemy and tell them to go away.
    var enemy = hero.findNearestEnemy();
    if(enemy) {
        hero.say("Go Away");
}
}

But when I try to complete the level, one of the goals are incomplete; it says I have to Rally the troops. I do not understand how to “Rally the troops”. Please help.

1 Like

You have to be sure to say the name of the ogre peon for it to go away.

1 Like

Like this:

hero.say("Go away " + enemy.id + "!");
2 Likes