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

Code Challenge

I dont understend second part of this code challenge?

script.js
function returnValue(upper)
{


  var echo = return upper;
 return echo;


}

returnValue("Hello my 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

Ricky Johnston
Ricky Johnston
27,445 Points

Hey Tomas,

I think you're overcomplicating things here. The code challenge isn't as hard as you're making it.

The first part is looking for you to do just what it asks, create a new function that takes in an argument and returns it.

function returnValue(argument) {
  return argument;
}

That's it. Your function's done.

Then, outside of that function, the next step is asking you to create a variable named echo and assign it to the results of the function.

var echo = returnValue("string");

You can place that a few lines below the function. All together, your code will look like this:

function returnValue(argument) {
  return argument;
}

var echo = returnValue("string");

Hope this helps. Happy learning!