I cant understand what`s wrong with my hero moving code?
loop {
// Find coins and/or attack the enemy.
// Use flags and your special moves to win!
var items = this.findItems();
for (var a = 0; a < items.length; ++a) {
var enemy = this.findEnemies();
if (enemy.length > 0) {
for (var i = 0; i < enemy.length; ++i) {
var enemy1 = enemy[i];
this.attack(enemy1);
}
} else {
var item = items[a];
this.move({x: item.pos.x, y: item.pos.y});
}
}
}