I am stuck on this level. Everything works correctly, but my archers do not kill the last two enemies. There are no errors, but my archers did not survive so I can not complete the level. Could someone please help me achieve this?
function findStrongest(){
var enemies = hero.findEnemies();
var strongestBoi = null;
var health = 0;
for(var i = 0; i < enemies.length; i ++) {
var enemy = enemies[i];
if(enemy.health >= health) {
strongestBoi = enemy;
health = enemy.health;
}
}
return strongestBoi;
}
while (true){
var buddies = hero.findFriends();
for (var b=0; b < buddies.length; b++){
var buddy = buddies[b];
var target = findStrongest();
hero.command(buddy, "attack", target);
}
}