4.Build "rock, paper, scissors


#1

Someone please help me out, I really cannot see how my code is wrong but its keeps giving me "syntax error, unexpected else".... HELP ME!! :anguished:

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

/*if choice1 is rock*/
 else if (choice1 === "rock") {
     if (choice2 === "scissors") {
         return "rock wins"; }
     else {
        return "paper wins"; }
};

/*if choice1 is paper*/
else if (choice1 === "paper") {
    if (choice2 === "rock"){
         return "paper wins"; }
        else {
            return "scissors wins"; }

   };
}

#2

Hi you shoud not put the semicolon at the end of your else if statement } so remove them

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

do the same for the other


#3

ooooooooh :grinning: My word how did i not see that... thank you very much wizmarco


#4

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