Summit's Gate - Javascript Help

see How to (fast and ugly) debug witht he pet
You can stack while true loops this way:

// code
var  doors = hero.findByType("door");
var Gate = doors[2],
    InnerGate = doors[1],
    SanctumGate = doors[0];
// code
while (true){
  // code for catapults and ogres
  if (Gate.health > 0)
    hero.attack(Gate);
  else break;
}
// code
while (true){
  // code
  if (InnerGate .health > 0)
    hero.attack(InnerGate );
  else break;
}
// code....