I am having a MASSIVE problem with the "What if choice1 is paper?"


#1



I get a message that says, "Oops, try again. There was a problem with your syntax." and in the console it says, "SyntaxError: Unexpected token else."


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

your if and else:

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

should be nested inside your else if:

else if (choice1 === "rock"){
   // if and else here
}

#3

it's this, you have an opening brace and closing brace, this line may as well not even be there.
You need to move the closing brace to after

Also, you have some weird indenting going on. Placing the brace will get you past the lesson, but it's important tot always be clean. I suggest going back and indenting where you want to see the indents.


#4

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