Build R,P,S, compare


#1

Instructions:
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";
}
else{
return "scissors wins";
}
};

error message:

SyntaxError: Unexpected token else


#2

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


#3

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!


#5

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


#6

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