// Patrol the village entrances.
// If you find an enemy, attack it.
var leftEnemy = hero.findNearestEnemy();
var rightenemy = hero.findNearestEnemy(); if (rightenemy) hero.attack(rightenemy); hero.attack(enemy); } // Now move to the right entrance. hero.moveXY(60, 31); // Find the rightEnemy. // Use "if" to attack if there is a rightEnemy. var enemy = hero.findNearestEnemy(); if (enemy) hero.attack(enemy); I don't know what is wrong with my code but it says that attack's argument should have type object but got null. Is there always a target to attack? (use if?)