8/9 what if choice1 is scissors


#1

having some troubles its not wanting to run for some reason and i have no idea why...

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

#2

you seem to close your function a bit early:

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

i marked it with a <- , that closing curly brackets closes the function, that should be after all the condition checking, remove it, then on the next line:

else if (choice1 === "scissors" {

you are are missing a )

Then you are missing some semi-colons, but that is nothing to critical


#4

thank you very much this helped but where am I missing some ;?


#5

You're welcome, your last else statement:

else
{
        return "scissors wins" <- missing semi-colon
}

your function closing and function calling:

} <- missing ;
compare(userChoice, computerChoice) <- missing ;

`