Lurkers Javascript



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.

Shouldn’t it be enemies.length instead? @Vanessa

1 Like

shouldn’t
enemyIndex += 1
be inside the while loop?

1 Like

Tried both of those and got the same result

is there supposed to be two of these } not just one?

1 Like

No, those brackets are complete lol.

oh okay
i wasn’t sure because i’m 99% better at python

whats your current code?

The same as the top, I tried both of Aya and your suggestions

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

:sob:

(20 chars is crying too)

question, are all enemies shamans?

1 Like

no there is also sand yaks

Nope, but doesnt this piece say only if its a shaman??

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)

My latest code is the one at the top. I tried qwertys and your suggestions. The level is non-subscriber.

1 Like

(post deleted by author)

i changed this bit to:

}
}
enemyIndex++;
}

and it worked for me

yes this would make sense because you need to increment enemyIndex after you kill the shamans