What if choice1 is paper?


#1

What's wrong?
Writes Syntax Error: Unexpected token else


#2

you only need two closing brackets at the end.


#3


#4

There is no closing curly brace for the else if(choice1==="rock").


#5

Why are need there two extra curly braces, I do not understand


#6

There is a closing bracket


#7

You need a closing bracket before the second "else if"


#8

@biff75 is correct you need two closing curly brackets after this line,

return "paper wins";

and two closing curly brackets after this line,

return "scissors wins";


#9

it would be a lot easier to make corrections to the code if it had been copied and pasted. Screenshots make it a little harder.

So, on line 16 of @webhero 's code, line 16 has the curly brace for the else if. Line 17 has the curly brace for the if. Line 19 has the closing brace for the if. Line 20 has the opening brace for the else. Line 22 has the closing brace for the else.

Where is the closing brace for the else if on line 16? You have a brace on line 30 which closes your else if from line 23. It's the exact same syntax. I'm guessing you erased it by error when putting together your else if for choice === paper.


#10

Thank you for the detailed answer!
I really missed the closing curly brace for the first else if...


#11

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