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 trialDaniel Borden
4,888 PointsPassing an argument to a function, objective #2 I can't seem to make this work.
I can't seem to make this work. Please help.
function returnValue(anything) {
var echo = anything;
return echo;
}
returnValue("I hope this works.");
<!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
Steven Parker
231,269 PointsYou have all the parts, just not in the right places. The echo variable needs to be outside the function, to receive the result of calling the function.
So, after moving things around a bit it might look like this:
SPOILER ALERT
function returnValue(anything) {
return anything;
}
var echo = returnValue("I hope this works.");
I like your sense of humor, I think I also named my argument "anything".
anil rahman
7,786 PointsIt says after your function do the echo you did it inside the function.
function returnValue(value)
{
return value;
}
var echo = returnValue("hello");
Daniel Borden
4,888 PointsThank you Anil.
Daniel Borden
4,888 PointsDaniel Borden
4,888 PointsThank you Steven. Problem solved.