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

Justin Oswald
Justin Oswald
5,969 Points

After trying multiple answers, I am not sure what the question is asking for.

I am stumped Im not sure what the error is

script.js
function returnValue(lable) {
  var echo = "hey " + lable;
  return lable
}
returnValue('friend');
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

Andreas Nyström
Andreas Nyström
8,887 Points

Hi buddy!

You have done the right thing with the function (task one). It's like this:

function returnValue(myArgument) {
  return myArgument;
}

However when you want to do the variabel you're complicating it a little bit. Just set the variabel to be the value of the returned string from your function. Like this:

var echo = returnValue('Hello!');

So together it's like this:

function returnValue(myArgument) {
  return myArgument;
}

var echo = returnValue('Hello!');

It's basically the same as saying that the variabel echo = "Hello!"; But it passes through a function, which is what you're learning now. Hope this helps! If you have more questions just ask.