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 trialJose Mendoza
UX Design Techdegree Graduate 19,788 PointsI have no idea how to set "var echo" to the "returnValue"
I have been stuck on this challenge for a while now and I need some help. Step 2 is asking me to set the variable "echo" to the returned results from "returnValue". I honestly don't understand how all of this works. Could anyone elaborate on what's going on here? What am I missing?
function returnValue( name ) {
return name;
var echo = returnValue;
}
returnValue('Jose');
2 Answers
Jacob Mishkin
23,118 PointsHi Jose Mendoza, you are really close on this one. only one thing to change, and that is the var echo needs to be out side of the function. and you need to call the function as well. like so
var echo = returnValue("Jose");
what is happing here is you are taking the return value of the function and placing it into the var echo. You were close you had the var echo inside the function and called the function by itself not in the var echo.
Gianmarco Mazzoran
22,076 PointsHi,
the second step of this challenge ask you to create a variable called "echo" after the function, which means that need to be created outside the function returnValue. Then set the value of the variable "echo" to be the results from calling the returnValue function, that's basically said that you have to simply call the function and last they recommend that you pass the parameter in a string format.
Like this:
function returnValue(name) {
return name;
}
var echo = returnValue('Jose');
Jose Mendoza
UX Design Techdegree Graduate 19,788 PointsJose Mendoza
UX Design Techdegree Graduate 19,788 PointsOh! that makes a lot more sense. I wasn't too sure why I was putting the variable echo inside of my function. Thanks again!
Jacob Mishkin
23,118 PointsJacob Mishkin
23,118 PointsNo worries, any time!