How do I complete this level? I keep receiving Statement execution limit reached error if I do what it asks of me in the hints. Here is my code.
// 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 arrays length with: enemies.length
while(enemyIndex < enemies.length) {
var enemy = enemies[enemyIndex];
// "!=" means "not equal to."
if (enemy.type != "sand-yak") {
// While the enemys health is greater than 0, attack it!
if (enemy.health > 0) {
hero.attack(enemy);
if (hero.bash.cooldown === 0) {
hero.bash(enemy);
}
}
enemyIndex += 1;
}
}
// Between waves, move back to the center.
}
Sorry if it’s messy, I’ve just been stuck here for a while.
Thanks,
CaptainCritz.