Completing Rock, Paper, Scissors


#1

I got to the part of reactivating the original command from notes after programming the outcomes of rock, paper, and scissor being pulled by the cpu, & it's looking like my code should run right, but when I run it I'm getting a "make sure to call your compare function" & it won't go through. I've spent the past few hours on this lesson, & I'm simply not seeing where I might've gone wrong... I originally thought subbing the "choice1" with "userChoice" (etc.) would've been the fix, but apparently that isn't so...

Here's the code I ran (after amending) if anyone has any suggestions:

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


#2

In your compare function the parameters need to be choice1 and choice2 instead of userChoice and computerChoice.
To call a function you simply need to put functionName(parameter 1, parameter 2); under your old code.