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

Can you please help me break down the code on task two?

I am having a hard time arriving at the solution. Can you please provide the lines for task two?

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

There's no need to create an echo variable inside the function. They just wanted you to return the value in the parameter.

function returnValue(Ellie) {
  return Ellie; 
}
var echo = returnValue("Ellie");

Here you are calling the returnValue() function with one String argument ("Ellie"). The function takes it and returns it. Then the value is assigned to the echo variable.