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 trial

JavaScript JavaScript Basics (Retired) Creating Reusable Code with Functions Passing an Argument to a Function

the var is echo

what am I missing

script.js
function returnValue(value) 
{
 return value;
}
var echo
return echo;
index.html
<!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>
Moosa Bonomali
Moosa Bonomali
6,297 Points

Your function declaration was sufficient for the challenge. Which is to create a function that returns the values passed into it;

function returnValue(value) 
{
 return value;
}

Did you intend to do something other than that?

2 Answers

shay elbaz
shay elbaz
2,885 Points

function returnValue(arg){ return arg; }

I think the problem is that after your function declaration you are creating a variable and then returning immediately after. The syntax here wouldn't work.

The second step in the challenge wants you to assign a value to a variable by calling the function with an argument.

The first part of this is right:

function returnValue(value) 
{
 return value;
}

The second part immediately after should look like this:

var echo = returnValue('myString');

What the above is doing is creating the variable echo and then assigning it to the value returned by the function you created called returnValue. That function takes in one argument which is expected to be a string (not explicitly but because the challenge expects it to be a string). The string that you specify as the argument is then returned by the function and assigned to the variable you declared earlier.