Help with game


#1

where is the mistake, would really appreciate any help

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"
        }
    } 
 
 
 }else if (choice1 === "scissors") {
        if (choice2 === "rock") {
            return "rock wins"
        }
        else 
        
         {return "scissors wins"}
        }
    } 
    compare(userChoice, computerChoice)


#2

HI this part

var compare=function(choice1, choice2) 
  {
     if(choice1 === choice2 ){ 
    {
        return "The result is a tie";
}

you have two open { you should remove one then here

....
}else if (choice1 === "paper") {
        if (choice2 === "rock") {
            return "paper wins"
        } else {
            return "scissors wins"
        }
    } 
 } <-- remove this one
....

you closed the compare function earlier so remove it.


#3

You should fix your indentation, this could help you find the problem.

You have opened brackets 2 times in first if statement:

if(choice1 === choice2 ){ // first here
     { // second here
    return "The result is a tie";
}

And 2 times closed in else if here:

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


} else if (choice1 === "scissors") { // second here at start of the line

Use JSBeautifier, this could help you correct your indentation. Your function will look like this:

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


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

compare(userChoice, computerChoice)