Code work but not marking as complete?


#1

All this works but I don't understand where I'm going wrong and have tried searching for help but none is relevant to the mistakes I have made:

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(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 win";
    }
}
else {
    if (choice2 === "paper") {
        return "scissors win";
    }
    else {
        return "rock wins";
    }
};
};

var choice1 = userChoice;
var choice2 = computerChoice;

compare(choice1,computerChoice)

#2

HELLO! i'm going to try to help you since i'm not an expert. But i can see that here:

var compare = function(userChoice,computerChoice)

when creating the function the parameters should be (choice1, choice2). for the function to work.
Also at the end:

var choice1 = userChoice;
var choice2 = computerChoice;

you only need to call the function with the parameters (userChoice, computerChoice)

ex: compare (userChoice, computerChoice);

these parameters will replace choice1 and choice2 in the function...
and check if the semicolon after the closing brackets of the if statement is giving you syntax errors.
Good luck. keep the good work.