What if choice1 is scissors? help plz


#1

hi I made this code:
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 === "scissors")
{
return "scissors wins";
}
else
{
return "paper wins";
}
}
else if(userChoice === "scissors")
{
if(computerChoice === "rock")
{
return "rock wins";
}
else
{
return "scissors wins";
}
}
};
but every time I run it they say: Oops, try again. Make sure to call your compare function with userChoice and computerChoice as the arguments!


#2

@byterockstar84812,

Please read
http://www.codecademy.com/forum_questions/559dcb4be39efe550f00006b
and concentrate on:

  • the execution of the compare function (keeping in mind that the return statement is used )

#3

call your function which you created, at last(i.e: compare function)..use userChoice and computerChoice as arguments to call that function..u forgot that above..Sorry, if I am mistaken..