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

suggestions on returnvalue not reading variable

variables and returnvalue

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

You seem to have the right mindset here, but you just need to change some of the order of your code:

function returnValue(x) {
 return x; 
}

var echo = returnValue('Hi There!');

Is what I did to complete the code challenge. You are declaring "var echo" in the function. You should move this outside the function and have it tied to your returnValue ("echo"); statement. You can then delete the alert line as well.

1 Answer

Antonio De Rose
Antonio De Rose
20,885 Points
function returnValue (str) {
 var echo //this is not where you've been asked to store,  so you can delete this line
return str;  
}
alert("echo"); // this is not needed, you will have to only action against the question
returnValue ('echo');  //this is where you have been asked to store with the echo variable