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

After your newly created returnValue function, create a new variable named echo. Set the value of echo to be the results

please answer this question

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

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, mo sam ! My guess (based on your code) is that for step 1 you had this:

function returnValue(name){
  return name;
} 

The second step of the challenge starts with this:

After your newly created returnValue function, create a new variable named echo.

But your echo variable isn't after the function, it's inside it. We want to run this function and assign the value of whatever it returns to the variable echo. So to alter your code to pass (it wouldn't be by much) you could do this:

function returnValue(name){
   // name will now be equal to "Mohammed" when called
   return name;
} 

// create variable and call the function sending in "Mohammed"
// The echo variable is assigned the result "Mohammed" which is returned from the function
var echo = returnValue("Mohammad");

Hope this helps! :sparkles:

Adam Beer
Adam Beer
11,314 Points

You are near. There is a two ways. First, save the name in a variable, and finally return the value of variable, like this.

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

or Second, return the value right away, like this,

function returnValue(name){
  return name;
} 
returnValue("Mohammad");

Thanks alot

Steven Parker
Steven Parker
231,236 Points

But you'd still need to assign "echo" using the result of the function call.