Help on Noble Sacrifice Javascript CS4

I did what the code told me to but it keeps displaying an error.

var item = hero.findNearestItem();
while (hero.gold < 80) {
    var item = hero.findNearestItem();
    if (item) {
        hero.moveXY(item.pos.x, item.pos.y);
    }
}
hero.buildXY("soldier", 13, 73);
hero.buildXY("soldier", 51, 73);
hero.buildXY("soldier", 51, 53);
hero.buildXY("soldier", 90, 53);
var points = [];
points[0] = {
    x: 13,
    y: 73
};
points[1] = {
    x: 51,
    y: 73
};
points[2] = {
    x: 51,
    y: 53
};
points[3] = {
    x: 90,
    y: 52
};
var friend = hero.findFriends();
if (friend) {
    for (var i = 3; i > -1; i){
        hero.command(friend, "move", points[i]);
        friendIndex++;
    }
}

[Code removed by a moderator: Please don’t post successful solutions as it is counterproductive to the learning process]

Hi can you please remove the completed and successful code? It’s to prevent people from copying your code which defeats the purpose of learning through CodeCombat. Thank you!