need help. am I doing it right? the second loop seems problem. I don’t know what it is. -_-’
// First, loop through all enemies...
var enemies = hero.findEnemies();
var enemyIndex = 0;
// ... but only attack "thrower" type enemies.
while (true) {
var enemy = enemies[enemyIndex];
if(enemy) {
if(enemy.type === "thrower") {
hero.attack(enemy);
}
}
enemyIndex +=1;
}
// Then loop through all the enemies again...
enemies = hero.findEnemies();
enemyIndex = 0;
// ... and defeat everyone who's still standing.
while ( enemyIndex < enemies.length ) {
enemy = enemies[enemyIndex];
while(enemy.health > 0) {
hero.attack(enemy);
}
enemyIndex +=1;
}