hello, guys i dont inderstand why im stuck in this lvl can i have help plz…
function findWeakestEnemy() {
var enemies = hero.findEnemies();
var weakest = null;
var leastHealth = 99999;
var enemyIndex = 0;
while (enemyIndex < enemies.length) {
var enemy = enemies[enemyIndex];
if (enemy.health < leastHealth) {
var weakset = enemy;
leastHealth = enemy.health;
}
enemyIndex +=1;
}
return weakest;
}
while(true) {
// Find the weakest enemy with the function:
var weakestShaman = findWeakestEnemy();
// If the weakest enemy exists:
if (weakestShaman) {
// Attack it!
hero.attack(weakestShaman);
}
}