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 trialCarleen Hall
Front End Web Development Techdegree Student 3,158 PointsGiving information to functions
Giving Information to a function. I am completely stumped on this one. Can someone explain.? Thanks
Challenge Task 2 of 2 After your newly created returnValue function, create a new variable named echo. Set the value of echo to be the results from calling the returnValue function. When you call the returnValue function, make sure to pass in any string you'd like for the parameter. β¨β¨The function will accept the string you pass to it and return it back (using the return statement). Then your echo variable will be set with what is returned, the results
Here is my code.
function returnValue(Nike){
var echo =
return Nike;
}
Carleen Hall
Front End Web Development Techdegree Student 3,158 PointsI don't understand "setting the value of echo to be the results from calling the returnValue function". I feel I understood everything when watching Dave's video. But now it's clear I don't understand. I watch the video several times trying to make sense of this challenge but it does not help. Hopefully, you understand what I am trying to say. :)
2 Answers
Jonathan Grieve
Treehouse Moderator 91,253 PointsHi Carleen.
What you want to do here is "call" the function. That is invoke the function do make it do something. In this case you're returning a value.
function returnValue(Nike){
return Nike;
}
The value it takes is determined when you make the function call and this comes after the function itself.
var echo = returnValue("Nike");
So this is where you declare you variable. you then assign the function call to it and see between the parentheses... where you put your Nike parameter. You can then put any string you like in there as the value.
And the full code...
function returnValue(Nike){
return Nike;
}
var echo = returnValue("Nike");
Carleen Hall
Front End Web Development Techdegree Student 3,158 PointsThanks, Jonathan, I think where my confusions lie is in thinking that return is used to end the function, therefore I thought that the "var echo" should be the last thing in the programme. Eventually I will get it.
Jonathan Grieve
Treehouse Moderator 91,253 Pointslet me know if you need anything else clarified :)
Christian Andersson
8,712 PointsChristian Andersson
8,712 PointsGreetings Carleen Hall,
I'd gladly assist, but could you first explain what you have tried and what, in particular, you find difficult or confusing? It will help me help you :)