4. Rock, Paper, Scissors 8/9 Unexpected Token; Else


#1

Help Me! I'm trying to do the last if/else code!

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 win";
        }
    }
    else if(choice1 === "scissors"){
        
        if(choice2 === "paper"){
            return"scissors win";
        }
        else
        {
            return"rock wins";
        }

     }
};

Thanks Guys


#2

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

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

here you miss a } to close the else if before you start with the next else if.


#3

hii please can you help me! it says expected expression got keyword 'else' !! thanksss
var compare=function(choice1,choice2){
var choice1= userChoice ;
var choice2= computerChoice ;
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==="scissors")  {
        return "scissors wins";
    }
    else { 
        return "paper wins";
    }
else if(choice1 === "scissors") {
    if(choice2 === "paper") {
        return "scissors wins";
    } else {
        return "rock wins";
    }
}