Exercise 5: rock,paper, scissor


#1

Help me to get the result.

“Oops, try again. Your compare function does not return ‘The result is a tie!’ when there is a tie.” this was my error.

Here is my 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 tie”;
}
};


#2

The string should be exact same what the lesson expects


#3

Thank you.
I’ve wasted more than half an hour.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.