Help! codecombat blind distance


i,am stuck at the blind distance here is the code

// Tell the wizard the distance to the coming ogres.

// This function finds the nearest enemy and returns the distance to it.
function nearestEnemyDistance() {
var enemy = hero.findNearestEnemy();
// If there is no enemy, the function returns 0.
var result = 0;
if (enemy) {
result = hero.distanceTo(enemy);
return result;

while (true) {
// Call nearestEnemyDistance() and
// save the result in the variable enemyDistance.
var enemyDistance = nearestEnemyDistance();
// If the enemyDistance is greater than 0:
// Say the value of enemyDistance variable.


As the level tells you to do: if enemyDistance is greater than 0, say the value of enemyDistance. What’s with the 22 and 11? The enemy is not always one of the two. Try:

if (enemyDistance > 0) {

Or something like that (my JavaScript sucks…lol)

In the future, also be sure to correctly format your code :slight_smile:


gimme a screenshot.:sunglasses::four_leaf_clover:


hellenar you just gave me the writ code :wink:


@Hellenar gave you a solution to the part which was wrong. That is okay.