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

storing return value

I need help with this code, I really don't understand why it wont pass. I rewatched the supporting video several times and am just not getting it. It keep saying "it doesn't look like you are storing the return variable." Thanks!

function returnValue(width) { var echo=width; return echo; }

returnValue('30');

script.js
function returnValue(width) {
  var echo = width;
  return echo;
}
returnValue('30');
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>

1 Answer

Hi,

I think you just got a little mixed up from the way the question is worded.

The function needs to simply return its argument...

function returnValue(val) {
  return val;
}

After that you need to store an argument passed to the function in a variable named "echo"...

var echo = returnValue("My argument");

All together you should have this...

function returnValue(val) {
  return val;
}

var echo = returnValue("My argument");

Hope this helps :)

Craig

It worked..thanks so much!!