Village Wander helppp! (javascript)

When I run this code, my hero does not attack the orgs. The orgs continue to go to the villager and attacks them. Can someone help me with this problem?

}
}

// Define a function to cleave enemies (but only when the ability is ready).
function findAndCleaveEnemy() {
// Find the nearest enemy:
var enemy = hero.findNearestEnemy();
// If an enemy exists:
if (enemy) {

}
    // And if "cleave" is ready:
    var ready = hero.isReady("cleave");
        // It's time to cleave!
        hero.cleave(enemy);

}

// In your main loop, patrol, cleave, and attack.
while (true) {
// Move to the patrol point, cleave, and attack.
hero.moveXY(35, 34);
findAndCleaveEnemy();
findAndAttackEnemy();

// Move to the other point:
hero.moveXY(60, 31);
// Use findAndCleaveEnemy function:
findAndCleaveEnemy();
// Use findAndAttackEnemy function:
findAndAttackEnemy();

}

Please could you fully format your code. Put ```javascript on a single line before your code then three backticks after your code.
Thanks

It doesn’t matter anymore my teacher told me the answer✅

but thanks for the help

1 Like