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

I've misplaced it?

I'm missing something?

script.js
function returnValue(echo) 
{

 return value (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

It should be like this;

function returnValue(echo) 
{
 return echo;
 }

3 Answers

Moosa Bonomali
Moosa Bonomali
6,297 Points

Try this to return the value passed into the function;

function returnValue(echo) 
{
 return echo;
 }

that works except it says the var is not called

Adam Beer
Adam Beer
11,314 Points

After the return delete the value and the brackets. And now when you call the function inside a variable and pass it to the value, your value will be returned.

Myles Young
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Myles Young
Full Stack JavaScript Techdegree Graduate 22,056 Points

So the reason you would want to return (echo) is bc in the function you created the main value you want to return is the parameter that you passed in your function (echo). Now if you return value(echo) you can get an error bc value would be undefined. Another thing you could do is declare β€œvalue” as a variable, and then set its value to your parameter (echo). Then your original answer would be valid also