Can someone help me with the problems with my code?


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

}
}


#2

What exactly is the issue you're experiencing?


#3

There seems to be a problem with my syntax?


#4

I am new so this is just a guess based on what my function looks like and yours looks like because mine worked.
At the end of your code you have two bracets {
1- is closing the "else" statement and one is closing the original "else if" statement that the new if and else statements are in. You need a third bracket closing the entire if then function.

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