What if choice1 is paper?


#1

Here is my code but for some reason it keeps giving me an error message and I've checked and copied over from other places. Does anyone know what I have done wrong?

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


#2

Hi this part its missing the open } of the else if statement

else if(choice1 === "rock")  { #i's was missing that {
    if(choice2 === "scissors"){
        return "rock wins";
    }
    else{
        return "paper wins";
    }
}

Then at the end add one } for closing the compare function


#3

I can't believe I missed it in that part. LOL. The system took the code the first time, so I didn't think to check there. Thank you so much.


#4

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