Ring bearer javasccrpt

// You must escort a powerful magical ring back to town to be studied.
// The goal is to escape, not fight. More ogres lurk in the surrounding mountains!
// Make a circle of soldiers around the peasant!
// We give you two functions to help with this:

// findSoldierOffset figures out the position a soldier should stand at in relation to the peasant.
// The first argument 'soldiers' should be an array of your soldiers.
// The second argument 'i' is the index of the soldier (in soldiers) you want to find the position for.
function findSoldierOffset(soldiers, i) {
    var soldier = soldiers[i];
    var angle = i * 360 / soldiers.length;
    return radialToCartesian(5, angle);
}

// This function does the math to determine the offset a soldier should stand at.
function radialToCartesian(radius, degrees) {
    var radians = Math.PI / 180 * degrees;
    var xOffset = radius * Math.cos(radians);
    var yOffset = radius * Math.sin(radians);
    return {x: xOffset, y: yOffset};
}

var peasant = hero.findByType("peasant")[0];

// Use findByType to get an array of your soldiers.
while(true) {
    // Use a for-loop to iterate over your array of soldiers.
    var soldiers = hero.findByType("soldier");
    for (var i = 0; i < soldiers.length; i ++) {
        var soldier = soldiers[i];
        var offset = findSoldierOffset(soldier, i);
        hero.command(soldier, "move", {'x': offset.pos.x + peasant.pos.x, 'y': offset.pos.y + peasant.pos.y});
    }
    // Find the offset for a soldier.
    // Add the offset.x and offset.y to the peasant's pos.x and pos.y.
    // Command the soldier to move to the new offset position.
    
    // The hero should keep pace with the peasant!
    hero.move({x: hero.pos.x + 0.2, y: hero.pos.y});
}

i get error at this part “offset.pos.x” and it say cannot have property x of underfined

You don’t seem to have used these in any of the rest of your code. Try adjusting to implement these variables.

like this ?

`var x = offset.pos.x + peasant.pos.x;
 var y = offset.pos.y + peasant.pos.y;
`

it seem not working i get the same error.