SyntaxError: Unexpected keyword 'else' for 7.What if choice is paper?


#1



https://www.codecademy.com/en/courses/javascript-beginner-en-Bthev-mskY8/1/3?curriculum_id=506324b3a7dffd00020bf661#


Its a syntax error regarding else


var compare=function(choice1, choice2){
    if(choice1===choice2){
        return "The result is a tie!";
    }
    else if(choice1==="rock"){
        if(choice2==="scissors"){
            return "rock wins";
            }
            else{
                return "paper wins";
                }
              else if(choice1==="paper"){
                  if(choice2==="rock"){
                      return "paper wins";
                      }
                      else{
                          return "scissors wins";
                          }
                }  
        }
    
    };


#2

you should close (with closing curly bracket (})) your else if choice1 is rock before starting with your else if choice1 is paper:

else if(choice1==="rock"){
        if(choice2==="scissors"){
            return "rock wins";
            }
            else{
                return "paper wins";
                }
         /* missing } */
              else if(choice1==="paper"){

i think you the closing curly bracket, but it is to late in the code, keep good track of which closing curly bracket closes what


#3

I see. I think thats something they should amend in the exercise. To be aware of it. Thank you very much.