Summit's Gate, can't get behind the tower, since it doesn't recognize it

I’m trying to get behind the tower, just to know it is being recognized, but my === tower doesn’t work. Besides, when I still have 900 health Tharin gets frozen and does no longer attack the second tower. He stays still close to the second opened gate till life is taken from him. Please Help!!

// Fight your way into the Inner Sanctum of the ogre chieftain, and kill her.

this.commandPaladin = function(paladin) {
    var nearestEnemy = paladin.findNearest(this.findEnemies());
    if (paladin.canCast("heal")) {
        this.command(paladin, "cast", "heal", this);
    }
    else if (paladin.health < paladin.maxHealth /3) {
        this.command(paladin, "shield");
    }    
    else if (nearestEnemy) {
        this.command(paladin, "attack", nearestEnemy);
    }
    else {
        this.command(paladin, "move", this.pos);
    }
};

this.commandFighter = function(friend) {
    var enemy = friend.findNearestEnemy();
    if (enemy) {
        this.command(friend, "attack", enemy);
    }
};

this.summonGriffin = function(){
    if (this.gold >= this.costOf("griffin-rider")) {
        this.summon("griffin-rider");
    }
};

this.commandFriends = function() {
    // Command your friends.
    var friends = this.findFriends();
    for(var i=0; i < friends.length; i++) {
        var friend = friends[i];
        if (friend.type === "soldier" || friend.type === "archer" || friend.type === "griffin-rider") {
            this.commandFighter(friend);
        } else if (friend.type === "paladin") {
            this.commandPaladin(friend);
        }
    }
};

loop {
    this.commandFriends();
    this.summonGriffin();
    var enemy = this.findNearest(this.findEnemies());
    var tower = this.findByType("tower");
    if (enemy && enemy != tower) {
        if (this.isReady("chain-lightning")) {
            this.cast("chain-lightning", enemy);
        }
        else if (this.isReady("cleave")) {
            this.cleave(enemy);
        }
        else {
            this.attack(enemy);
            this.bash(enemy);
        }
    }
    else if (enemy && enemy === tower){
         this.moveXY(110, 4);
    }
}

First of all, you define tower as a list of all the towers. You then try to check if an enemy is this list. This does not work. The real syntax is using the string "tower" as a type check. Also, != is Python syntax. JavaScript uses !==.

JavaScript has both != and !== (as well as their counterpart == and ===). The difference is that ==/!= perform type casting, while ===/!== do not. E.g.:

// With type casting:
1 == '1'; // true, the types are different but values are the same

// Without type casting:
1 === '1'; // false, the types are different

Most styleguides prefer ===/!==, because ==/!='s type casting does quite a bit of magic leading to unexpected results in certain cases.