Build rock, paper, scissors - Question 7 HELP!


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

else if(choice1 === "paper") {

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

what am i doing wrong!


#2

It says -- SyntaxError: Unexpected token else


#3

at return scissors wins" you forget a ;


#4

Still the same error


#5

else if(choice1 === "rock") {
    
      if(choice2 === "scissors") {
        return "rock wins";
    }
    else {
        return "paper wins";
}
/* oops, missing } to close else if  */
else if(choice1 === "paper") {

see comment, you forgot to close your else if, which causes a problem


#6

Thanks it worked :slightly_smiling: really helpful