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

Stumped

What am I doing wrong?

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

2 Answers

Grace Kelly
Grace Kelly
33,990 Points

Hi Rene, you have the right idea except for a couple of minor things.

This code challenge requires for us to create a function that returns a value:

function returnValue(x) {
  return x;  
}

Below this we then declare a variable called echo and assign the returned value of the returnValue() function to it:

var echo = returnValue("Treehouse");

Hope that helps!!

Andrew Cousineau
Andrew Cousineau
17,320 Points

The second part of the coding challenge is to define the echo variable AFTER the function. You currently have the echo variable assigned within the function.

Here is more of what you're looking for...

function returnValue( string ) {
  return string;  
}

var echo = // you got this ;)