Help #7


#1



Stuck on exercise 7 (What if choice1 is paper?). Can anyone spot what I'm doing wrong, please?


SyntaxError: Unexpected token else


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 thi spart you cloed the else if statement earlier

    else if (choice1 === "rock") {
        if (choice2 === "scissors") {
            return "Rock wins";
        }
    } <-- remove this one
        else {
            return "Paper wins";
        }
}

then at the end of your code you should add one } for closing the compare function


#3

Thank you, wizmarco!


#4

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