Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


I know it's the last block of conditional statements that are preventing my code from running. Someone please help!

I have just started learning Javascript and decided to mock one of treehouses challenges and re-create it in Atom. I have commented out the last block conditional statement and my code runs, (but doesn't print the 'ranking' messages). I also got a syntax error code from Chrome dec tools, "Uncaught SyntaxError: Unexpected token {" on line 41. I thought that the ' (correct <= 3) ' was correct syntax. Someone, please help!

This is my code:


1 Answer

Steven Parker
Steven Parker
225,726 Points

A plain "else" doesn't take a conditional expression. It's designed to handle all cases not already taken by the "if" and/or "else if" chain that precedes it.

But if you want it to handle cases where "correct" is less than or equal to 2, you'll need to change the condition of the previous "if". Perhaps you meant to use ">= 3" instead of "<= 3"?

And unless I've missed something in recent news, the correct number of states in the United States is still 50. :wink:

Thank you so much for taking the time to review my code and give me this helpful answer! I simply deleted the last "else" statement and changed the "if" statement to ">= 3" and now it runs perfectly! I appreciate your time! && yeah I done goofed on the states aha. Have a great rest of your weekend!