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 trialDayne Wright
11,235 PointsWhy do you not need to create a parameter in a function with var?
I am curious as to why you do not need to create a variable first for the parameter you pass into a function. Is there a reason why it does not need it?
1 Answer
Jonathan Grieve
Treehouse Moderator 91,253 PointsI think it's because this challenge is asking you to create a variable in local scope. And that's what you're doing when you're passing in the parameter to the function returnValue
. At the parameter stage, your first argument is a placeholder variable which is then given a value at function call.
function returnValue(one) {
return one;
}
var echo = returnValue("My argument");
It's only when the function is called in the last line that JS knows what value to display in the "one" placeholder variable. :-)