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 trialLeo Penaloza
8,426 PointsUsing return values
What's the difference between using the Return value and just letting the code finish?
2 Answers
Steven Parker
231,236 PointsIf you use a plain "return;
", there's no difference from just hitting the end of the function.
But if you use it to return a value (like "return someValue;
") it sends that value back to the point of the program that called the function, where just hitting the end does not.
Leo Penaloza
8,426 Pointsso it continues from where the function last left off?
Steven Parker
231,236 PointsWhen the function ends, either by reaching the closing brace or from a "return", the program continues from the point where the function was called.