I need help with the code!


#1

My code doesn’t work for the Useful Competitors Level and there is always one coin in the top left still there.

while(true) {
    var enemy = hero.findNearestEnemy();
    if(enemy) {
        if(enemy.type != "peon") {
            hero.attack(enemy);
        }
    }
    var item = hero.findNearestItem();
    if(item) {
        // Gather the item only if the type is NOT equal to "poison".
        var itemX = item.pos.x;
        var itemY = item.pos.y
        if (item.type != "poison") {
            hero.moveXY(itemX, itemY);
        }
    }
}

#2

Your missing a ; on the line of var itemY = item.pos.y


#3

thanks for the help!!!