8/9 Return statements don't appear to declare winner



I'm not stuck. Code was approved. Not sure why return statements don't appear when game is played. Please help.

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("User: " + userChoice);
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";
                return "paper wins";
                else if (userChoice === "paper"){
                        if (computerChoice === "rock") {
                            return "paper wins";
                            return "scissors wins";


console.log("User: " + userChoice);

This line of code try erasing it and then saving it because it worked just fine for me.


did it print "rock/paper/scissors wins"? when I play the game it only shows me what the user and computer's choices were and nothing else.


Mine didn't print who wins mine just printed the computers answer


I guess it's a bug. I even tried swapping all the returns out for console.log and nothing changed.


So was my answer the solution???


Not quite, I understand why it prints out the computer's choice. To me it's unclear why the code doesn't also print out any of the "rock/paper/scissors wins" statements.


You need to call out the function after the coding.

compare(userChoice, computerChoice);


Yeh, that solved my problem.


the code always ran. I don't get why there isn't a "rock/paper/scissors wins" return statement printing out.


Is it a capitalization error? That's what was happening to me (on the input I was capitalizing "Rock" but it's lower case in the code). You also need to add the piece arrayninja mentioned, but add console.log (I think).

console.log(compare(userChoice, computerChoice));


i have the same problem too..!!!
i don't know why this is happening....


thanks to @legendsoftomorrow @shenchris @juanpalmero @jonathandalby @csswhiz63937 for confirming I wasn't the only one having an issue and for working towards a solution