"SyntaxError: Unexpected token else" – #6 "What if choice1 is rock?"


#1



URGH -_-

"SyntaxError: Unexpected token else"
I have been stuck on this exercise for about 30 minutes. It keeps telling me the same thing over and over again even though I have tried many possible solutions via some pleas for help that other users have asked for. It's extremely frustrating. Help! Please.


/*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";
}
};


#2

Try adding a { after if (choice1 === choice2)


#3

I have tried that but it keeps saying "Syntax Error: Unexpected token else".

/*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";
}
};


#4

Try deleting the ; here as well.


#5

HALLELUJER! :tada:
I never thought that I would see that "Way to go! Start Next Lesson" button/icon again! Thanks for the help!


#6

I know the feeling :joy: Glad I could help!