8/9 unexpected token { help!


#1
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!";
   console.log(compare);
}

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 are forgetting a closing-parenthesis-) in your choice2-IF-condition

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

and please read
http://www.codecademy.com/forum_questions/559dcb4be39efe550f00006b
and concentrate on executing the compare function

PS.
What is the purpose of
console.log( compare );


#3

thank you so much! also I saw that on another persons question as I was trying to figure it out before asking a question, can't believe I missed it!


#4

Also this console.log is ignored as it comes after a return:

return "The result is a tie!";
console.log(compare);

and here you miss the closing } for the else if:

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

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

maybe it get's easier to spot the missing }s when you format your code :smile: