SyntaxError: expected expression, got keyword 'else'


SyntaxError: expected expression, got keyword 'else'

If (computerChoice <= 0.33)
{computerChoice = "rock";}
else if (computerChoice < 0.67)
{computerChoice = "paper"; }
{computerChoice = "scissors"; }

I would appreciate it if some one could pint out what I am missing here. thanks

-Update: I used the above spacing for (my) readability, here is the more standard one, which changes the error message to:
SyntaxError: missing before statement

If (computerChoice <= 0.33) {
computerChoice = "rock";
} else if (computerChoice < 0.67) {
computerChoice = "paper";
} else { computerChoice = "scissors";

Again, thank to anyone who can help


(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)


Thank you for checking my code and your response.
I have checked the spelling numerous, counted the round and curly brackets pairs. I can not see which semicolon is missing. I have one after each "then" action, but none after a condition and nine after a closed curly brackets, ie 3 "then" action = 3 semicolons.

Can you please point out what I am missing?
Thank you.

Don't worry, I worked around it.


@taxsyn We have answered your question here:

You can ask questions at, and we aim to answer quickly


why wouldn't you need the and (&&) operator?


if (computerChoice <= 0.33) {
else if (computerChoice >= 0.34 && computerChoice <= 0.66) {
else {


Maybe just because you need to use lowercase in "if".


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