CS4 16. Lurkers

I am having issues with this level, I keep reaching the statement execution limit somehow

My code is below in JS

// findEnemies returns a list of all your enemies.
// Only attack shamans. Don't attack yaks!
var enemies = hero.findEnemies();
var enemyIndex = 0;
// Wrap this section in a while loop to iterate all enemies.
// While the enemyIndex is less than the length of enemies
while (enemyIndex > enemies.length) {
    var enemy = enemies[enemyIndex];
    if (enemy.type == 'shaman') {
        while (enemy.health > 0) {
            hero.attack(enemy);
        }
    }
    var enemyIndex = enemyIndex + 1;
}    // Remember to increment enemyIndex

Hi @iv7n.
I checked your code, the problem appears to be on line 7, the while loop.
The hint is // While the enemyIndex is less than the length of enemies.
You used the > symbol, which is used to determine whether or not something is greater than something else. Switching it to < (‘less than’) should fix your problem.
Hopefully this helps,

-Marmite

I switched it around and it still does not work

Edit: I managed to beat the level by brute force, and equipping powerful gear. I know its not the intended method but if you have enameled dragon set and a powerful sword you can just use a loop:

while(true) {
    var enemy = hero.findNearestEnemy();
    if (enemy.type != "sank-yak") {
        hero.attack(enemy);
    }
}