This.getNearest(units) returns null

I cannot get nearest unit from custom array, as this.getNearest return null (?)

this.getSoldiersNearBase = function(units){
var arr = ;
for(var i=0;i<units.length;++i){
var u = units[i];
if((u.type===‘soldier’ || u.type===“knight”) && u.pos.x>70) arr.push([u]);

return arr;

this.defendBase = function(threat){

this.attack(threat); //ArgumentError is not defined at this line;
if(!this.getCooldown('throw')) this.throw(threat);
if(!this.getCooldown('jump'))  this.jumpTo(threat);

var enemies = this.getEnemies();
var soldierNearBase = this.getSoldiersNearBase(enemies);
if(soldierNearBase.length > 0){

var threat = this.getNearest(soldierNearBase);
this.say(soldierNearBase); //this simple say is to check, that soldierNerBase really constains units

// at this moment threat does not contain any information.
/if ask “this.say(threat)” compilier returns “say what?”

Found the problem; it’s that you are pushing [u] instead of u, so you end up with this array of arrays of units instead of an array of units like this.getNearest() is expecting.

Thanks for spotting that typo