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! While you're at it, check out some resources Treehouse students have shared here.
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 trialLuka Sarich
13,204 PointsI 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!
1 Answer
Steven Parker
230,945 PointsA 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.
Luka Sarich
13,204 PointsThank 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!
Luka Sarich
13,204 PointsLuka Sarich
13,204 PointsThis is my code:
https://postimg.cc/Cnx1DTCx