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 trialTatiane Lima
6,738 Pointswhat is wrong in my code
/* THIS IS THE QUESTION 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. */
function returnValue(singleArgument) {
var echo = singleArgument;
return echo;
}
returnValue(exemplo);
Mod note: Added formatting to the javascript code so we could see more easily
4 Answers
Jonathan Grieve
Treehouse Moderator 91,253 PointsLet's walk through what the challenge is asking for.
First, create the function block
function returnValue(argument) {
return argument;
}
So this function will take a string as a value and expects a return statement to return the value back to the function. Use the parameter as the return value.
Having done this you then declare a variable, outside of the function. Then assign a function call to the variable.
function returnValue(arg) {
return arg;
}
var echo = returnValue("String");
Where the string is the argument that is passed into the function.
Good luck.
Steven Parker
231,269 PointsThe challenge says "After your newly created returnValue function..."
You should leave the function as it was in the previous task step. Then create the echo variable below the function and not inside it.
You will assign the value to echo by calling the function, something like this:
let echo = returnValue("some string");
Tatiane Lima
6,738 PointsI already know the correct answer:
function returnValue(singleArgument) { return singleArgument; } var echo = returnValue("example");
But the message of error of this question wasn't helpful :(
Tatiane Lima
6,738 Pointsthanks guys! :)