Magic Eight Ball Project error

At the end of the Magic Eight Ball project, I did the “extra practice” of changing my switch statement into if/else if/else statements.

For some reason, the else statement at the end of my if/else if/else expression created an error. I don’t understand why! If I changed else into else if the code works properly. Is there something different about an else statement that means it needs different syntax?

I received this error:

Thank you for your help!

Hi @mistabreeze
an else statement works without a condition. Than you write

if (condition) {
// your code
} else {
// your code which will be executed if the if condition doesn't fit
}

If you have another condition, you’d always write it as else if (condition)

4 Likes