Double Gaps

// Get the hero and the peasant to the south.

// The function move your hero down along the center line.
function moveDownCenter() {
var x = 40;
var y = hero.pos.y - 12;
    hero.moveXY(hero.pos.x, hero.pos.y);
}
// The function build a fence on the right of something.
function buildRightOf(something) {
    // buildXY a "fence" 20 meters to something's right.
    hero.buildXY("fence", something.pos.x + 20, something.pos.y - 20);
}
// The function build a fence on the left of something.
function buildLeftOf(something) {
    // buildXY a "fence" 20 meters to something's left.
    hero.buildXY("fence", something.pos.x - 20, something.pos.y + 20 );
}
while(true) {
    var ogre = hero.findNearestEnemy();
    var coin = hero.findNearestItem();
    if (ogre) {
        buildLeftOf(ogre);
    }
    if (coin) {
        buildRightOf(coin);
    }
    moveDownCenter();
}

Please someone help,

im

really stuck.

Hi, there are a few problems with this.
Firstly this line:

What’s the point of creating x and y variables if you don’t use them?
And these two lines:

You’re building a fence to either the left or the right of an object. Why are you changing the y property. Y governs up and down, and X governs left and Right.

When formatting your code in java script, remember to put ‘javascript’ after the three backticks at the start of your code so it recognizes the comments.

Danny

I am sorry, but I don’t understand

[en_US.composer.my_buttons_text]

what u mean, those two pieces of code with var x and y were originally there.

@Deadpool198
Never mind I got it, Thank you!