8/9 passing but the var compare arguments don't show the return


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

};

console.log(compare)


Computer: scissors
[Function]

Why do none of my compare returns show?


#2

Hi @pyrunner46174

When you call your compare function, you have to put 2 parameters (userChoice and computerChoice) :

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

And you have to create 3 else if like this :

else if(userChoice === "rock")

else if(userChoice === "paper")

else if(userChoice === "scissors")

Hold on :wink: