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

Help for Backwood Brawl (Javascript

#1

Hi guys,

I am trying to utilise an if statement within an if statement, I would like the hero to cleave if ready, but if not to sheild himself and if not to both, then attack.

while(true) {
var enemy = hero.findNearestEnemy();
var distance = hero.distanceTo(enemy);
if (distanc < 5) {
if (hero.isReady(“cleave”)) {
hero.cleave(enemy);
}
else {
hero.shield();

}

}
else {
hero.attack(enemy);
}
}

#2

Typo:
if (distanc < 5) {

#3

Yeah you misspelled that. It should work after you fix that. Also, remember to post your code according to the FAQ.
https://discourse.codecombat.com/faq