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

[SOLVED] Javascript Code Question



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")) {

   else {
    var enemy = hero.findNearestEnemy();




why are you defining enemy again, you don’t need to.


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.


indentation doesn’t matter in javascript, it only matters in python,


Thank you very much!



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.


it is not about brackets, it is about the language itself