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 trialVicki Corich
6,632 PointsI can't pass the second part of the challenge.
Here is the question-
Now that you've created the returnValue function, call it, by passing it a literal string value -- a series of characters in quote marks like this: 'My argument'. Store the results of the function in a variable named echo.
Thanks, Vicki
function returnValue(me){
var echo = 'hello';
return echo;
}
returnValue('hello');
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
4 Answers
Dan Oswalt
23,438 PointsHi Vicki, looks like it's asking you to pass the return value into 'echo', so:
function returnValue(me){
return me;
}
var echo = returnValue('hello');
Jason Anders
Treehouse Moderator 145,860 PointsHi Vicki,
If you're on the 2nd task, then you created the function correctly. Go back to that code and let's work from there.
The 2nd part doesn't ask you to do anything more with the code for the function, so I'm not sure why you put a variable inside the function. The task just wants you to call the function you created.
function returnValue(me) {
return me;
}
With the function already coded, you call a function by typing it's name returnValue();
. This function takes one argument, and the task just wants you to pass in any string and store the functions return value into a variable named echo.
The function is already returning the argument passed in, so to store it in a variable, you would just assign the called function to the variable. var echo = returnFunction("This is me");
This would go outside and after the function itself.
function returnValue(me) {
return me;
var echo = returnValue("This is now Me!");
Hope this makes sense. Keep Coding! :)
Vicki Corich
6,632 PointsThank you! I finally passed. What's the point of naming the returnValue but not using the name?
Schuyler Klaassen
5,446 PointsThis one also stumped me, and I felt really dumb for it. Either I didn't understand the wording of Part 2 or, after a couple of months of dabbling, I don't understand functions at all.
Yeah, I guess I don't understand (without some kind of math equation or puzzle) what we just did there.
M Atkins
586 PointsI was pretty confused with this Challenge as well. I don't really understand functions that well, but I will keep plugging away.