5/9, Compare() is created already?


Right, so here is the code:

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

I get the "Oops, try again. Did you create a function called compare?"

Why is this happening? I did create the function "compare" right?


The problem is that you are using choice instead of choice1. But the error message isn't really helpful at this point.


How could I miss that! Thanks bud :wink:


I still used choice 1 and choice 2, but it still doesn't recognize my compare function. I get an error saying computerChoice is not defined?


Could you post your code pls?


my entire code

var userChoice = prompt ("do you choose rock, paper or scissors?")

var computerChoice = Math.random(0,3)

console.log (computerChoice)

if (computerChoice >= 1){
} else if (computerchoice >= 2){
var compare = function (choice1,choice2) {
if (choice1 === choice2) {
return "The result is a tie!";


maybe your problem is that you deleted the comment tags /**/ at the beginning and end.

my whole 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(choice1, choice2) {
if(choice1 === choice2) {
return "The result is a tie!";


Math.random doesn't take arguement so 0,3 will just be ignored and it still goes from 0 to 1. If you want to change the range you might multiply it by 3 and then Math.floor() it (round down to the next integer value). Currently none of your cases is possible so the computer always ends up with scissors. Also you should assign the value to computerChoice and not just console.log them.