Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Help with Backwoods Standoff

I’ve been working on this level for a while, here’s my code:

    var enemy = hero.findNearestEnemy();
    // Use an if-statement with isReady to check "cleave":
    if (hero.isReady("cleave")); {
        // Cleave!
        hero.cleave();
    }
    // Else, if cleave is not ready:
        else {
        // Attack the nearest ogre!
        hero.attack(enemy);
        }
}

I’m using javascript, but when I try typing in else, it keeps telling me "Expected an identifier and instead saw “else”. I can’t really figure it out. If someone could help me that would be great, thanks!

Hi iDraco…welcome to the forum!

Can you post your entire code?..looks like you are missing the outer while loop. (Good catch on the formatting tho!)-never mind, I see it in your edit.

Based on what you are now showing, the only thing I see is the else clause is out of alignment…

1 Like

and on further review…get rid of the semi-colon ‘;’ at the end of your isReady(“cleave”) line.