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

Joshua Emery
Joshua Emery
1,164 Points

variable doesn't contain the value? yet the alert command i've added to check it's working does contain the return?

I'm getting seriously confused it won't let me proceed because the variable 'echo' doesn'tcontain argument..yet the alert states it does?!??!

script.js
function returnValue(argument) {
  var echo = alert(argument + " why is this not working") ;
return argument 
}
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>

2 Answers

Joshua Emery
Joshua Emery
1,164 Points

Thanks! Seems simple now! I was over thinking it

so the first part of the challenge asks you to create a function that returns the argument passed into the function. It could be as simple as:

function returnValue(argument) {
  return argument;

the second part asks for you to assign the function returnValue() to a variable called echo, passing in the argument as a string, which would look something like this:

var echo = returnValue('any string');

I hope this helps clear things up!