8/9 SyntaxError: Unexpected token


#1

It always says "SyntaxError: Unexpected token )" What's the mistake?

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 (userChoice, computerChoice) {
    if (userChoice === computerChoice) {
        return "The result is a tie!";
    }
    else if (userChoice === "rock") {
        if(computerChoice === "scissors") {
            return "rock wins";
        }
        else {
            return "paper wins";
        }
    }
    else if (userChoice === "paper") {
        if (computerChoice === "rock") {
            return "paper wins";
        }
        else {
            return "scissors wins";
        }
    }
    else if (userChoice === "scissors") {
        if (computerChoice === "rock") {
            return "rock wins");
        }
        else {
            return "scissors wins");
        }
    }
    console.log(compare(userChoice, computerChoice));
};

"Rock, Paper, Scissors" part 8
#2

here you have a ) at the end which is not needed. Also your function call is inside of your function which makes it rather pointless, move it outside to run the function.


#3

Sorry, but how do I move the function outside? It's so much to learn in short time and as a german it's not easier, because everything is written in english. But I don't know an other websites who's that good like this website.


#4

Okay, now it works... I had a second ) mistake :unamused:


#5

Läuft der code jetzt? Es gibt glaube ich auch ne deutsche Version von dem JS Track, aber im Zweifel enthält die englische weniger Bugs :wink:


#6

Jo, läuft :smiley: Dat meiste versteh ich ja auch, an sich is dat ja kein Problem ^^.