Why is the Unexpected token else error getting?

  • 0
    let SeeLater = 'See you later.';
        let fash = '.Barry' ; 
        let vyraz = prompt('Enter access code ', '');
    
      if (vyraz == 2545) {
          let Name = prompt('Enter your name. ', ''); 
          let lastname = prompt (`Enter your last name. `, ''); 
        alert(`Welcome to V. A. S. ${Name} ${lastname}.`);
        let information = prompt(`What you need Dr.${lastname} ?`, '');
           
       } 
      
              if (information == 'RF ') {
                alert ('RF is negative .');} 
                if (confirm (`Anything else, Dr.${lastname}?`)){
                  alert ('RF = - .');
              let information = prompt (`Anything else, Dr.${lastname}? `);
                  
                }
      
                  if(information == 'Fash') {
                   alert (fash);
                     } 
                     else {
                     alert (SeeLater);
                      }
          
              
                      else{
                       alert (`See you later Dr.${lastname}.`);
                        }
               else if(information == 'Fash ') { alert (' Barry. ');}
       else {
                  alert ('No info today');
                } 
        
                 else {
        alert ('Access is closed ');
             
              }
    JavaScript Anonymous, Oct 17, 2020

  • 3 Answers
  • 0
    else {
    alert (SeeLater);
    }
    else {
    ...
    }
    else if {
    ...
    }
    else {
    ...
    }
    else {
    ...
    }
    Nothing confused? Observe the design style, there will be no such stupid questions.
    Anonymous

  • 0
    these 3 else are clearly not in the subject.



    else {
    alert(`See you later Dr.${lastname}.`);
    }
    else ...




    else {
    alert('Access is closed ');

    }
    Anonymous

  • 0
    A piece of your code:

    if (information == 'Fash') {
    alert(fash);
    } else {
    alert(SeeLater);
    } else {
    alert(`See you later Dr.${lastname}.`);
    } else if (information == 'Fash ') {
    alert(' Barry. ');
    } else {
    alert('No info today');
    } else {
    alert('Access is closed ');
    }




    You cannot have two else in a row.
    Paige Bullock

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!