What if choice1 is "paper"?


#1


Can someone please let me know what I am doing wrong, I've been stuck on this for a while changing everything back and forth and still end up with the same error.


I am getting the error message "SyntaxError: Unexpected keyword 'else'"


function compare(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 this else if statement you close } it ealier you should close it after the else statement like that

else if(choice1 === "rock") {
} <-- #remove this one 

    if(choice2 === "scissors") { 
        return "rock wins!"
    }

    else {
        return "paper wins"
    }
} <-- #Add this one

Do teh same for the other else if statement


#3

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