Stuck on lesson 7 What if choice1 is paper?


#1


I keep getting a syntax error. What's wrong?
var compare() = function(choice1, choice2) {
if (choice1 === choice2) {
return "The result is a tie!";
}
else if (choice1 === "rock") {
if (choice2 === "scissors") {
return "rock wins";
}
else {
return "paper wins";
}
}
else if (choice1 === "paper"){
if (choice2 === "rock"){
return "paper wins";
}
else{
return "scissors wins";
}
}


Replace this line with your code.


#2

Hi add one } at the end for closing the compare function

var compare = function(choice1, choice2) {
   //here put all the if, else if and else statement
};

then this line

var compare() = function(choice1, choice2)

remove the () to the compare should be like that

var compare = function(choice1, choice2)

#3

Could you type the code in a future comment? That would be helpful.


#4

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