I need help in the one wizard

this is my code

while(true) {
var enemy = hero.findNearestEnemy();

if (enemy){
var distance = hero.distanceTo(enemy);}
if (enemy.type == “ogre”) {
hero.moveXY(10, 36);
}

    else if (distance < 10 && hero.canCast("chain-lightning", enemy)){
        hero.cast("chain-lightning", enemy);}
        
    else if (hero.canCast("lightning-bolt"), enemy){
        hero.cast("lightning-bolt", enemy);}
        
    
        
     if (hero.canCast("regen") && hero.health < 50){
        hero.cast("regen", hero);}
    else if (enemy){
        hero.attack(enemy);}

}

please format all your code correctly
what seems to be the problem?