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 trialGesang Lamu
2,742 PointsJS Basics Stage5 function challenge
is this asking what I wrote below? Not sure if I can nest function like this, am I thinking too much? Don't laugh if I did something ridiculous.
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.
var echo = function(){
function returnValue(a){
return a; } returnValue("My argument");
};
var echo = function(){
function returnValue(a){
return a;
}
returnValue("My argument");
};
<!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>
2 Answers
Rich Bagley
25,869 PointsHi Gesang,
Your code would look somthing similar to this:
function returnValue(arg){
return arg;
}
var echo = returnValue('My argument');
You are first creating the function which is passing in the function with:
function returnValue(arg){
return arg;
}
You are then using this function and passing in your argument with this part:
returnValue('My argument');
Finally you're storing this value in the variable with:
var echo = returnValue('My argument');
Hope that helps
-Rich
Travis Stewart
15,188 PointsThanks Gesang and Rich. Both for posting and for answering. I spent about 10 minutes over-thinking this problem.
Rich Bagley
25,869 PointsNo problem :)
Gesang Lamu
2,742 Pointsvery glad that I posted !! :)
Gesang Lamu
2,742 PointsGesang Lamu
2,742 PointsHi Rich,
That helps a lot!! thank you, thats right, it asking to store the result of the function not literally the entire block of the the function like I did.
Rich Bagley
25,869 PointsRich Bagley
25,869 PointsNo problem. Happy to help :)