Forest fire dancing level

while (true) {
var evilstone = hero.findNearestItem();
if (evilstone) {
var pos = evilstone.pos;
if (pos.x == 34) { // == means “is equal to”
// If the evilstone is on the left, go to the right side.
hero.moveXY(46,22);
}
} else {
// If the evilstone is on the right, go to the left side.
hero.moveXY(34,22);
}
} else {
// If there’s no evilstone, go to the middle.
hero.moveXY(40,22);
}
}
Can anyone help ?

Welcome to the discourse. This is a place thats cozy for chatting! and helping each other with code! (“IVE SAID THIS WAY TOO MANY TIMES”) please learn to format your code with the </> to improve readbility

you used

else {
    hero.moveXY(x, y)
}

when you should use

else if(pos.x == number) {
    hero.moveXY(x, y)
}