I don't know why my code for uneasy truce doesn't work. - Javascript

// Summon one soldier for every ogre to the south of you!
// Don’t count the ogres to the north!

// Accept an array of units as the parameter.
// Return only the units to the south of the hero.
function findSouthernUnits(units) {
var southernUnits = [];
for(var i=0; i < units.length; i++) {
var unit = units[i];
if(unit.pos.y < hero.pos.y) {
// Add the unit to the array with: push()
return southernUnits;

while(true) {
var friends = hero.findFriends();
var enemies = hero.findEnemies();
// Use findSouthernUnits to get enemies to the south.
if (findSouthernUnits(enemies) > friends) {
// If there are more ogres south of you than friends.
// Then summon another “soldier”.

Shouldn’t it work?

if (findSouthernUnits(enemies) > friends) {

Compare arrays length
length is represent amount of units


Thanks @htrnblr that helps so much. I can’t believe I didn’t realise “Facepalm”