mzz
1
Hi,
Trying to figure out what I’ve done wrong here. Trying to use this loop for Kithgard Brawl.
while (true) {
var enemy = hero.findNearestEnemy();
if (hero.isReady("cleave")) {
hero.cleave(enemy);
}
else {
var enemy = hero.findNearestEnemy();
hero.attack(enemy);
}
}
Thanks!
1 Like
kyay10
2
why are you defining enemy again, you don’t need to.
kyay10
3
and you should surround this code with if(enemy) because sometimes you won’t be able to find an enemy
Why does it seem that indentation is wrong, the while at the top is indented, but the other lines and loops are not.
1 Like
kyay10
5
indentation doesn’t matter in javascript, it only matters in python,
kyay10
8
you are welcome (Post must be at least 20 characters)
So as long as code is within brackets and such, indentation is not necessary, unless you want it to be organized.
kyay10
10
it is not about brackets, it is about the language itself