The result is a tie error


#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 (choice1, choice2)
{
if (choice1 === choice2)
{
return " The result is a tie! ";
}
};
compare(userChoice,computerChoice);

Even though my output page is showing"The result is a tie". I'm getting this error: Your compare function does not return 'The result is a tie!' when there is a tie.


#2

if (choice1 === choice2)
{
return "The result is a tie!";
}
compare("rock","rock");

replace your code with this one
you only check for the difference
in both, although both look same

this rock input was just to check, and at this point you should avoid uncommenting the code, because it will then prompt for the users input and the computers selection is random, so its very less likely to be a tie !!


#3

Thanks for the explanation (y)


#4

Seems like your having an extra space after the! The rest seems to be ok.