Summit's Gate - Javascript Help

Errors in your code

function commandUnits(friends) {
      else // not needed
        var commandable = null; // not needed

function heroAction() {
    else // not needed 
        var attack = null; // not needed

function removeDoors(enemies){
    var enemies1 = [];
    for(var i=0;i<enemies.length; i++){
        var enemy = enemies[i];
        if (enemy.type !=door) { // must be "door"
            enemies1.push(enemy);
        }
    }
    return enemies; // must be enemies1
}

So the first while true loop where you kill all enemies except the door can be:

// outside the loop
// you can retreat ( or some of ) your units not to be killed from the first catapult shots
// cast chain-lightning to the nearest fangrider etc...
while(true) {
    var enemies = removeDoors(hero.findEnemies());
    // put your command functions here  
    if (!enemies.length) break; // break the loop when enemies.length === 0
}

what spell book do you have? the speed ring?

i reccomend the unholy tomb v