The result is a tie error


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! ";

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.


if (choice1 === choice2)
return "The result is a tie!";

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 !!


Thanks for the explanation (y)


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