If choice1 is scissors?


Hi, I'm having a little trouble figuring out why my code is wrong...it says "unexpected token {" when I try to execute it, but after going through it, and even cross-checking with another person's code, I'm still unable to figure out why it is wrong. If someone could check my code, and even see if there is anything else I can do to make it better (still kind-of a rookie), that'd be great!

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
} console.log("Computer: " + computerChoice);

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";
    else (choice1 === "scissors"){
        if (choice2=== "rock"){
            return "rock wins";
        else return "scissors wins";
compare(userChoice, computerChoice);


Hi your last else if statment you wrote just else instead of else if (choice1 === "scissors")


Is it supposed to be "else if"? It is my last statement in the whole if-else statement so I thought we keep it as "else"


UPDATE: What you said was correct, but I'm still a little confused...why do I add an "else if" instead of else?


Hi I think that we didn't put the else stament becoze if you remenber the else statement don't take any condition but here we need that all the statement has a condition so is why the last stetemnt isn't else.