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 trial

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements The Conditional Challenge

jameshamoore
jameshamoore
15,550 Points

HELP! I can't figure out what's wrong with my code.

Here is a screenshot of my workspace: https://w.trhou.se/eylsym022i

I've tested the code and everything seems to work fine until I get to the very last line of code. My last else statement makes the who code, not run at all it seems. Can someone please tell me what's wrong with it?

2 Answers

Steven Parker
Steven Parker
231,007 Points

A plain "else" doesn't take a conditional expression, and doesn't need one since it handles any case not covered by the previous "if" and "else if" statements. Giving it an expression causes a syntax error.

If you want, you could optionally show the condition you expect it to handle in a comment:

} else /* results === 0 */ {
jameshamoore
jameshamoore
15,550 Points

Oh okay, I get what I was doing wrong now. Thank you so much. I had been stuck there for hours and couldn't understand why it was wrong.