6/9 Unexpected Token if


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

What is the problem? It keeps saying I have an Unknown token.


#2

This is mine and it passes fine.

function compare(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 {

}
}


#3

You aren't using the given quoted returns:
you used "Rock Wins"
and "Paper Wins"

when the given ones don't contain any capital letters: "rock wins" and "paper wins"

(for some reason its case sensitive)


#4

But, that's not the problem. I've run into that problem before. This is saying that there is an unexpected Token "If". I've tried everything I can think of, Even changing the capital letters...


#5

This should work. There should be a starting bracket and a final bracket to link the whole thing together

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