Clash of Clones JS HELP ME!

For some reason if I run my code that is supposed to find the last enemy in an array of all enemies it breaks:

var enemies = hero.findEnemies();

while(true) {
var enemy = enemies[enemies.length - 1];
    if ( <= 131 & enemy !== null) {

can you post your equipment and level screenshot please

That is not what I need-I spent all my gems on upgrading. The problem is my guy just sits there.

you could just use enemy = hero.findNearestEnemy(its python i don’t like java script)

that didnt work either
for some reason neither work

If that doesn’t work, then try replacing this line:

var enemy = enemies[enemies.length - 1];

With this:

var enemy = enemies[0];

And then check if there is an enemy first. Also, I would like to point out that because you have chosen to use an array that has bsem defined before the loop, you will only be attacking enemies in that array and it won’t update. Try putting:

var enemy = hero.findNearestEnemy()

At the beginning of the while true loop (inside it), check if there is an enemy, and then attack it. You may then use whatever abilities you may have.

1 Like