What is missing?


#1

Been stuck on it for ages. have no idea what i did wrong!

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

#2

What's the error you're receiving?

edit: Oh dear -- there's a lot of syntactical mishap here.

var compare = function (choice1, choice2){
    if (choice1 === choice2) {
    return "The result is a tie";
}

Firstly, you aren't closing the interior {. It needs to be closed. Secondly, just under that, you're starting an else if block without any occurring if block. Your else if should probably be inside of that compare() function.

Thirdly, near the bottom, you've var userChoice,computerChoice. I'm not sure what you're trying to accomplish with that line.


#3

I get this error

SyntaxError: Unexpected token }


#4

See my above post. That's probably happening, firstly, because of the code block I included regarding the compare() function, but note that there are more problems that you will need to sort out.


#5

I don't get what you mean


#6

What do you not understand?...

Read my posts.