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

Need help with part 2 of Passing an argument to a function

Having a lot of trouble with this challenge. It keeps saying cannot find variable 'Adam'. But this should work, correct? Can anyone guide me towards what this challenge is asking for? Thanks!

function returnValue(name) { 
  var echo = 'hello' + name;
  return name;
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
<script src="script.js"></script>

2 Answers

Sorry, didn't see you were looking for the answer to part 2. For the second part to this challenge, it should be set up like this.

function returnValue(name) { 
  return name;
var echo = 'Hello ' + returnValue('Adam');

The variable has to be defined outside of the function in order for it to be set as the output of returnValue. You can add strings to it here too.

Hope this helps! Dylan

Hey Adam,

you were really close to having this solved! All you needed were quotations around "Adam" to make it a string, JS was trying to take it in as a variable and causing errors.

function returnValue(name) { 
  var echo = 'hello' + name;
  return name;