Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Jonatan Luna
Jonatan Luna
2,554 Points

REALLY HELP!!! I dont really undesrtan the task

I don´t know how can do it?

script.js
function returnValue (width, length){
  var echo = returnValue (pepe);
  return echo;

}

returnValue(pepe);
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>
Gustavo Winter
Gustavo Winter
Courses Plus Student 27,382 Points

Hello jonatan, the objective of the task is: "This isn't that useful of a function, but we want to make sure that you know all of the important parts of creating a function that can accept parameters when it is called, before moving on to bigger functions."

Your code is:

function returnValue (width, length){
  var echo = returnValue (pepe);
  return echo;

}

returnValue(pepe);
}

You need this :

function returnValue(string){
 return string;
}

In your code above, you made two returns and assign a "var echo", This is not necessary once the task only ask for an immediately returns.

If it is helpful let me know, Or if you have any questions, please let me know.

2 Answers

Amrit Pandey
Amrit Pandey
17,595 Points
function returnValue (arg){
  return arg;
}

var someVariable = returnValue("Some String");
Amrit Pandey
Amrit Pandey
17,595 Points

If you can mark it as a Best Answer that'll be helpful :)