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

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 :)