Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Attack enemies in an array - JAVASCRIPT OR ANY

Hello, does anyone know what I’m doing wrong? Could someone please help me please :frowning:

image

var enemies = hero.findEnemies();
var enemyIndex = 0;
while (enemyIndex < enemies.length) {
    hero.say("HAY ENEMIGOS CERCA");
    var enemy = enemies[enemyIndex];
    if (enemy) {
        hero.attack(enemy);
    }
    enemyIndex += 1;
}

something that might help is deleting the “hero.say” statement because it’ll slow you down a lot