Borrowed sword code javascript

heres the code for borrrowed sword these guys make it too hard

// For this level, your hero doesn't fight.
// Command your archers to focus fire on the enemy with the most health!
while (true) {
    var enemy = hero.findNearestEnemy();
    var enemies = hero.findEnemies();
    var smallest = enemies[0];
    var friends = hero.findFriends();
    for (var i = 0; i < enemies.length; i++) {
        for (let j = 0; j < friends.length; j++) {
            let friend = friends[j];
            let enemy = enemies[i];
            if (enemies[i].health < smallest.health && enemies.health > 300) {
                smallest = enemies[i];
                hero.command(friend, "attack", smallest);
                hero.say(smallest);
            } 
            else {
                hero.command(friend, "attack", smallest);
            }
        }
    }
}

Your greater than sign is reversed; the archers are attacking the targets with the least health instead of the ones with the most health. Also && enemies.health > 300 makes them target smaller targets as well.