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 Express Basics Serving Static Files in Express Adding Static Assets to the App

return statement in if statement

id like to know why the tutor doesn't explain the use of the return statement in his if statement at the time of writing it........... i have spent many hours trying to resolve the errors in my console and did resolve them with the addition of a return statement, but why does the tutor not even mention those errors at the time of writing the if statement, he doesn't even acknowledge that the error exists until several lessons down the line, when i got those errors i thought i had done something wrong or incorrect ESPECIALLY since the tutor doesn't even acknowledge the errors in the video. and spent REALLY long time wondering where i had gone wrong etc, it would have saved me a on of time and frustration if the teacher had said "this will cause the following errors to occur in your console, but don't worry about that, we can fix it with a return statement" rather than waiting till several lessons down the line to explain the error and the solution. very annoyed by that.

1 Answer

Tim Oltman
Tim Oltman
7,730 Points

I had a similar experience. I ended up solving this error by wrapping the rest of the function in an else clause. I'm glad to know of the return solution now though.