Ive completed this level but had a question. If i had the variable outside of the loop or at the top of the loop instead of just before the attack it didn’t work, why is this?? shouldn’t a variable work in this case at the top?? I get the error i can’t see the enemy but if its following the loop that should matter as when i call the variable i can see the enemy?
FAIL…
loop{
var e = this.findNearestEnemy();
this.moveRight();
this.moveUp();
this.moveRight();
this.attack(e);
this.attack(e);
this.moveDown(2);
this.moveUp();
}
PASS ...
loop{
this.moveRight();
this.moveUp();
this.moveRight();
var e = this.findNearestEnemy();
this.attack(e);
this.attack(e);
this.moveDown(2);
this.moveUp();
}