I am having troubles with Brittle Morale. Even though I use a function to return the enemy with the highest health and say this enemy’s name, causing the archer to shoot the leader, the level does not succeed.
My code is as follows:
// You have one arrow. Make it count!
// This should return the enemy with the most health.
function findStrongestEnemy(enemies) {
// sorts enemies array descending by enemy health property
enemies.sort(function(a,b){
b.health - a.health;
});
// return Trogdor in sim (with 575 health), or whoever has most health
return enemies[0];
}
var enemies = hero.findEnemies();
var leader = findStrongestEnemy(enemies);
if (leader) {
hero.say(leader);
}