# Уровень не хочет работать

function findNearestPair(units) {
var minDistance = 9001;
var nearestPair = [“Nobody”, “Nobody”];
// You need to check and compare all pairs of units.
// Iterate all units with indexes “i” from 0 to “units.length”.
for(var i = 0; i < units.length; i++){
var unitA = units[i];
// Iterate all units again with indexes “j”.
for(var j = 0; j < units.length; j++){
// If “i” is equal to “j”, then skip (continue).
if(i == j){
continue;
}
var unitB = units[j];
// Find the distance between the i-th and j-th units.
var distance = unitA.distanceTo(unitB);
// If the distance less than ‘minDistance’:
if(distance < minDistance){
minDistance = distance
nearestPair = [unitA.id, unitB.id]
}
}
return nearestPair;
}
}

while (true) {
var soldiers = hero.findByType(“soldier”);
// We know when the cannon shoots.
if (hero.time % 8 === 5) {
// Find which pair of soldiers in danger and protect them.
var pairOfNames = findNearestPair(soldiers);
// Say the soldier’s names and wizards will protect them.
hero.say(pairOfNames[0] + " " + pairOfNames[1]);
}
}