// 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);
}
}
// Remember to increment enemyIndex
enemyIndex =+ 1;
Game gives me an error message on line 11- "TypeError: Cannot read property ‘type’ of undefined`
// 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);
}
}
// Remember to increment enemyIndex
enemyIndex =+ 1;
I’m not skilled in javascript, but I suppose you need to check “triple-combo” if there is an enemy and if his type == “shaman” and if his health > 0 before attacking. UPD
No I was wrong(
Idk what’s wrong exactly but something with enemy defining went wrong( I found another way to define enemy and now there is no pop-up messages about undefined, but my hero kills 2 of 3 shamans and freezes face to face with the 3rd one and code stops(
@Deadpool198 is completely right.
The thing is in syntax.
Try to click [hints] button above code editor field. Almost all work is done there in 3 hints)