I got a syntax error


#1



i got a syntax error


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

look, you have two open parenthesis, (, but one closing parenthesis ), so it is saying that you aren't closing your if / else if statement's conditional


#3

i dont understand. it is close

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

#4

no, the parenthesis, (), i pointed out where you had two of the left ones, but one of the right ones.

     if(choice2 === ( "rock"){
else if(choice1 === ("paper"){
       ^            ^       ^
    opening     opening  closing

you either need to add another closing one right before the {, or take the one in front of paper and rock away.


#5

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