What can i do, it just showing like this "SyntaxError: expected expression, got keyword 'else' "


#1

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 shouldn't have a closing tag before the if statements. It should look like so:

else if (choice1 === "rock") {
if (XYZ) {
return statement
}

You've done that in both places where you start your if statement. Get that sorted and then make sure to close those brackets at the end.
It should look something like so (at the end)

   }

}
};


#3

please send your code


#4

var compare = function(choice1,choice2) {
//Begin of FUNCTION-BODY
if (choice1 === choice2) {
//IF code-block with it's statements
return "The result is a tie!";
}

 else if (choice1 === "rock") {
          //ELSE-IF  code-block with it's statements
       if (choice2 === "scissors") {
          //IF  code-block with it's statements
          return "rock wins";
       } 
       else {
          //ELSE  code-block with it's statements
          return "paper wins";
      }
 } 

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

//End of FUNCTION-BODY
};
You should really try and make the amendments first instead of just copying and pasting. That doesn't do you any favours.