Need help on step 6: Unexpected Else


#1

So I was on part 6 of the Rock Paper Scissors and it keeps giving me "SyntaxError: Unexpected token else". I have looked on other threads but none of them are solving my problem.

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 (choice2 === "paper") {
          return "paper wins";
       }
   }
};


#2

; after if codition is a bad idea

if (choice1 === choice2); // remove ;

if(condition){

//block of code

}

and
else doesn't have condition


#3

Thank you very much.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.