Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Backwoods fork please help [javascript]

// Incoming ogres!
// Use the checkAndAttack function to make your code easy to read.

// This function has a parameter.
// An parameter is a way of passing information into a function.
function checkAndAttack(target) {
    // The 'target' parameter is just a variable!
    // It contains the argument when the function was called.
    if(target) {
    hero.moveXY(43, 34);

while(true) {
    hero.moveXY(58, 52);
    var topEnemy = hero.findNearestEnemy();
    // Move to the bottom X mark.
    hero.moveXY(58, 16);
    // Create a variable named bottomEnemy and find the nearest enemy.
    var bottomEnemy = hero.findNearestEnemy();
    // Use the checkAndAttack function, and include the bottomEnemy variable.

when my hero goes to the top X he just runs to the middle then bottom can some one tell me why that is?


Your code looks correct. Which equipment you are using?


this is my equipment i dont know what is wrong


nevermind i guess i was going too fast for my hero to find the enemy at the top thank you @Bryukh