5.Both choice are same


#1



https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/1/1?curriculum_id=506324b3a7dffd00020bf661#

your compare function does not return 'the result is a tie' when it is a tie. need help

/*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!";
}
};


#2

Hi your return statement should return

return "The result is a tie!";

#3

yes that is the problem i'm having


#4

Hi! try to rebuild your page or better click on the menu on left down corner and take again the lesson #5 both! choices are the same!.
after that, print your code again.
if your problem persist try to copy this code :sweat_smile::

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

just copy and Paste XD
cheers!!


#5

var choice1 = userChoice;
var choice2 = computerChoice;
var compare = function(choice1,choice2){
if (choice1 === choice2){
return "The result is a tie!";


#6

Why there is no semi colon after the compare function in your code?

BTW following is giving me a syntax error.

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


#7

There shouldn't be a semi colon, that's why the syntax error

@shilpabadve please open a new topic, code, error and lesson


#8