I my code doesn’t seem to work (JS):
loop {
var enemies = this.findEnemies();
var enemy = this.findNearest(enemies);
// Wrap this logic in a while loop to attack all enemies.
while (enemy.health > 0){
// "!=" means "not equal to."
if (enemy && (enemy.type != "sand-yak")) {
// While the enemy's health is greater than 0, attack it!
this.attack(enemy);
this.attack(enemy);
this.attack(enemy);
}
// Between waves, move back to the center.
}
this.moveXY(33, 40);
}
it seems to get stuck on "While (enemy.health>0)"
Please help.