The flow of your program should look like this:

Guess the secret number (1-100)
You have 3 turns left.

Too HIGH. Guess again
You have 2 turns left.

Too LOW. Guess again
You have 1 turn left.

You are correct! It took you 3 turns!

My program won't run at all and I can't find the problem. Also, am I going about it the right way or is there an easier shorter way of doing this than if/else?

Code:
  function main(){

    var secretNumber = "23"; //integer, holds correct answer
    var userGuess = "Welcome to the Number Guesser! " +" Guess the secret number between 1-100" +"\n You have 3 turns to guess the secret number."; //integer, holds guess answer

    while( userGuess != secretAnswer){
    
    if(userGuess == secretNumber){
      alert("Impressive! You guessed the secret number on your first turn.");
    
    }else{ 
    
    if(userGuess < secretNumber){
      alert("Too LOW.  Guess again." + '\n' + "You have 2 turn(s) left.");

    }else{
  
    if(userGuess > secretNumber){
      alert("Too HIGH.  Guess again." + '\n' + "You have 2 turn(s) left.");

  } // end if
  } // end if
  } // end if  
   
     userGuess = prompt("Guess the secret number (1-100). you have 2 turns left");

    if(userGuess == secretNumber){
      alert("Great! You got that on your second turn.");
    
    }else{ 
    
    if(userGuess < secretNumber){
      alert("Too LOW.  Guess again." + '\n' + "You have 1 turn(s) left.");

    }else{
  
    if(userGuess > secretNumber){
      alert("Too HIGH.  Guess again." + '\n' + "You have 1 turn(s) left.");


  } // end if
  } // end if
  } // end if  

 
    userGuess = prompt("Guess the secret number (1-100). you have 1 turns left");

    if(userGuess == secretNumber){
      alert("Nice guess! You got that in your last try.");
    
    }else{ 
    
    if(userGuess < secretNumber){
      alert("Too LOW.  Game over.");

    }else{
  
    if(userGuess > secretNumber){
      alert("Too HIGH.  Game over.");

  } // end if
  } // end if
  } // end if 

  } // end while
    
  } //end main function