Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Amandeep Pasricha14,932 Points
Do you always have to write a variable for a return value?
Hi, I know this sounds like an obvious question, but how we know when to make a variable or not. I was literally thinking of just putting Math.floor into the function without creating a variable for it. Why would that be wrong?
Do you always need to create a variable?
Steven Parker221,438 Points
The "return" statement takes any expression, it can be a variable, but it could also be a formula, literal, function call, etc.
return size * base + 2; // a calculation return price(item); // call another function return "Standard"; // a literal (string in this case)