# Rock, Paper, Scissors Problem

#1

The computer says ReferenceError: rock is not defined

``````var userChoice = prompt("Do you choose rock, paper or scissors?");
console.log("You:" + " " + userChoice)
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!";
}
else if(choice1 === rock) {
if(choice2 === scissors) {
return "You win!";
}
else {
return "Computer wins!";
}
}
else if(choice1 === paper) {
if(choice2 === rock) {
return "You win!";
}
else {
return "Computer wins!";
}
}
else if(choice1 === scissors) {
if(choice2 === rock) {
return "Computer wins!";
}
else {
return "You win!";
}
}
};
compare(userChoice, computerChoice)``````

#2

@gracegool,
Your `return` Value's are not what is required.....
The execution of your compare function will not give a Displayed result....

and concentrate on:

• the creation of the compare function
• the truth-table
• the build of the IF ELSE-IF statement structure as part of the compare FUNCTION-BODY
• the execution of the compare function (keeping in mind that the return statement is used )

#3

You forgot the parentheses here:

if(choice2 === scissors)

Here you are comparing the variable choice2 to the variable scissors. But scissors is no variable, it's a value. Therefore you need to put parentheses around scissors.

if(choice2 === "scissors")

You have to add parentheses for all 6 conditions tough!