7/13


#1

I don't see any problem with the following code, but it keeps telling me SyntaxError: Unexpected token 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

Hi, there are many mistakes your code. Please compare them. Especially keep an eye on { } and ;

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";
}
}
};

#3
 else if (choice1 ==="rock"){
        if(choice2 === "scissors")
        return "rock wins."}
        else{
        return "paper wins"}
}
else if (choice1 === "paper") {

this part is the problem. if you format it a bit:

 else if (choice1 ==="rock"){
        if(choice2 === "scissors")
            return "rock wins."
 }
 else{
     return "paper wins"}
 }
 else if (choice1 === "paper") {

you can see that with the 2. else if you have 2 else following each other which is not possible. Also do you know what you're doing by omiting the {} for the if? And example how this could look like is your 2. else if here you formatted the code and set correct {}.

@pointphoton Pls rather give hints than post solutions and if you post solutions pls format them so that they are readable e.g. use jsbeautifier.org or anything else if don't want to do this on your own.