You need to indent everything forward after the for and after the while.
Also i wouldn’t limit it to 3… you don’t know where in the enemies array those 3 shaman are. just do the loop while enemyIndex is less than or equals to enemies.length
you never update “enemies” inside the loop. If you have less than 3 shamans in the enemy list, enemyIndex will never reach 3, and the loop will never exit.
Make sure “enemies” object is updated within the loop, or you need to handle a case where there are less than 3 shamans.
Your indenting is a mess. You need to revisit the levels that teach you about python indenting. Or go google it.
from what i can see in the screenshot. the killed line needs to be indented forward. but i cant see everything. try posting your whole code in the forum.
put three of these characters on a line by itself both before and after your code… `
Hey just wondering if someone can help me out with this code i beat it using Python but Java is giving me probs ( i always get the error Hard execution limit 30000)
Heres my Code:
// Only attack shamans. Don't attack yaks!
var enemies = this.findEnemies();
var enemyIndex = 0;
while (enemyIndex < 3) {
var enemy = enemies[enemyIndex];
if (enemy.type == 'shaman') {
enemyIndex = enemyIndex + 1;
while (enemy.health > 0) {
this.attack(enemy);
}
}
}