What is wrong here please help:
// Recruit soldiers and archers to fill out each squadron.
// Each paladin has a decimal number stored in her deployment attribute.
// Convert these to binary and represent them with lines of soldiers and archers next to each paladin.
// Soldiers are 0s, archers are 1s.
// For the bonus goal, add griffins as 2s for trinary number lines next to the warlocks.
// Check the guide for help with binary numbers.
var paladins = hero.findByType("paladin");
for (var i = 0; i < paladins.length; i++) {
var paladin = paladins[i];
var n = paladin.deployment;
var devider = 2;
var result = [];
while (n > 0) {
if (n % devider !== 0) {
result.push(1);
n -= devider / 2;
} else {
result.push(0);
}
devider *= 2;
}
if (result.length < 8) {
for (var j = result.length; j < 8; j++) {
result.push(0);
}
}
result = result.reverse();
var posX = paladin.pos.x;
var posY = paladin.pos.y;
var built;
for (var bruhSoManyVars = 0; bruhSoManyVars < result.length; bruhSoManyVars++) {
var resultValue = result[bruhSoManyVars];
if (resultValue === 0) {
hero.summon("soldier");
built = hero.built;
hero.command(built[built.length], "move", {
"x": posX + bruhSoManyVars * 8,
"y": posY
});
} else {
hero.summon("archer");
built = hero.built;
hero.command(built[hero.built.length], "move", {
"x": posX + bruhSoManyVars * 8,
"y": posY
});
}
}
}