7.unexpected token else


#1

i dont know what im doing wrong
}
else if(choice1 === "paper")
{
if (choice2 === "rock")
{
return "paper wins";
}
else {
return "scissors wins";
}
}
someone help me


#2

Can you show the full code? I can see that you aren't showing your full code, which may have also called the problem.


#3

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";
}
}
};
here it is


#4

You see this that you put?

I'll put it in more detail :smiley:

Well, you see that that bracket has like, no meaning into it? So you need to put something into it, don't you?

What you were supposed to do was to put the if and else loop inside that else if loop, which you didn't do.

After revision:


#5

thanks a lot! :smile: it changed