Both choices are the same!


#1



What is wrong in this code? Please 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);*/
//compare(userChoice,computerChoice);
console.log(compare(userChoice,computerChoice));


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


#2

This line must come after the compare function, not before. The line attempting to access a function that is not yet defined.

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

console.log(compare(userChoice,computerChoice));

It will still throw an error since computerChoice and userChoice are not yet defined. Remove the /* and */ for the code above to test.

This exercise checks for the exact text given in the instructions:

    return "The result is a tie!";