Infinite Loop, Sarven Shepard

I’d come back to this level later if I didn’t need this level to progress through the game XD.
Since thats not the case I need help!
I tried to look for a solution by looking up to see if anyone else had problems with this level and didn’t help.
I tried looking back to previous levels for comparison and didn’t help either.

It keeps telling me that I’m stuck in a infinite loop and I don’t get why.
I think I’m following the instructions right but looks like the infinite error has a different opinion.

The below is my code work for the level.

// Use while loops to pick out the ogre

while(true) {
var enemies = hero.findEnemies();
var enemyIndex = 0;

// Wrap this logic in a while loop to attack all enemies.
// Find the array's length with:  enemies.length

while (enemyIndex < enemies.length) {
var enemy = enemies[enemyIndex];
// “!=” means "not equal to."
if (enemy.type != “sand-yak”) {
// While the enemy’s health is greater than 0, attack it!
while (enemy.health > 0) {hero.attack(enemy);}
}}

// Between waves, move back to the center.
hero.moveXY(40,32);

}

The above is my code work for the level.

Help me please!!!
Thanks in advance!!!

@HeroslasherX are you incrementing your LCV? (Loop Control Variable)

In this case your loop is being controlled by enemyIndex.

Was just trying that as your messaged popped up XD. Looks like it work thanks!!!