Mad Maxer: Redemption JS

ok
(i am going to write a topic about 20 chars)

// You can't reach your friends to defend them!
// Tell them to go home where the archer can help.
while (true) {
    var weakestFriend = null;
    var leastHealth = 9999;
    // Find which friend has the lowest health.
    var friends = hero.findFriends();
    for (var friendIndex = 0; friendIndex < friends.length; friendIndex++) {
        var friend = hero.findNearestFriend();
        if (friend.health < leastHealth) {
            leastHealth = friend.health;
            friendIndex++;
        }
        weakestFriend = friend;

        // Tell the weakest friends to go home first.
        if (weakestFriend) {
            hero.say("Hey " + weakestFriend.id + ", go home!");
        }
    }
}

This is my code now, I’ve gone from saving one friend to saving two friends, but still fail the level

Much better :clap:!
But still needs improvment.
So here is a small hint, how you must make your for loop:

for (var friend in friends) {
        // your code
        }

Next, your weakestFriend = friend; must be inside the check of friend.health

And finally move this statement

if (weakestFriend) {
            hero.say("Hey " + weakestFriend.id + ", go home!");
        }

out of your for loop