Help with Clash of Clones

If you search enemy hero read Easiest way to select the enemy hero.
Function findStrongestEnemy will return unexpected result. Try it yourself

while (true){
    var enemy = hero.findEnemies(); // obvious error 
    var leader = findStrongestEnemy(enemy);
    pet.say(leader);
    if(leader){
        hero.attack(leader);
    }
}