var enemies = hero.findEnemies();
var enemyIndex = 0;
while (enemyIndex < enemy.length) {
var enemy = enemies[enemyIndex];
if (enemy) {
if (enemy.type == 'shaman') {
while (enemy.health > 0) {
hero.attack(enemy);
}
}
}
}
enemyIndex += 1;
It says no error, it just says Ran out of time.
I can’t help, but the formatting looks a little off.
Aya
October 28, 2021, 3:19pm
4
Vanessa:
enemy.length
Shouldn’t it be enemies.length
instead? @Vanessa
1 Like
qwerty
October 28, 2021, 3:20pm
5
shouldn’t
enemyIndex += 1
be inside the while loop?
1 Like
Tried both of those and got the same result
qwerty
October 28, 2021, 3:40pm
7
is there supposed to be two of these }
not just one?
1 Like
No, those brackets are complete lol.
qwerty
October 28, 2021, 3:43pm
9
oh okay
i wasn’t sure because i’m 99% better at python
Vanessa
October 28, 2021, 3:45pm
11
The same as the top, I tried both of Aya and your suggestions
qwerty
October 28, 2021, 3:55pm
13
idk i changed it so that its the same as my py code (as in does the exact same struff) and it doesn’t work for me
Aya
October 28, 2021, 5:49pm
15
question, are all enemies shamans?
1 Like
qwerty
October 28, 2021, 5:57pm
16
no there is also sand yaks
Vanessa
October 28, 2021, 6:31pm
17
Nope, but doesnt this piece say only if its a shaman??
Aya
October 28, 2021, 6:49pm
18
It does, that’s why I’m asking. Can you post your latest code, and a screenshot of the level please
(because I’m not a subscriber and I cannot access the level)
Vanessa
October 28, 2021, 6:53pm
19
My latest code is the one at the top. I tried qwertys and your suggestions. The level is non-subscriber.
1 Like
yes this would make sense because you need to increment enemyIndex
after you kill the shamans