Build R,P,S, compare


Inside the compare() function under the existing code, write another else if statement where the condition is choice1 === "paper".
Inside this else if statement, write an if / else statement. If choice2 === "rock", return "paper wins". Else, return "scissors wins".

var compare=function(choice1, choice2){
if(choice1 === choice2){
 return  "The result is a tie!";  
else if(choice1 === "paper"){
if(choice2 === "rock"){
return "paper wins";
return "scissors wins";

error message:

SyntaxError: Unexpected token else


In your code on line 5, remove this bracket }. And after the line 12 add another bracket } .


Awesome! Thanks so much! Although, I don't quite understand why there is three } brackets on the bottom. If you could help me understand why I would greatly appreciate it!


Thanks so much! Yes, this makes more sense to me. If I know why something works it tends to stay with me.


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