Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics (Retired) Creating Reusable Code with Functions Passing an Argument to a Function

confused by where var echo should go

can someone explain what this task is asking

function returnValue(Fred) {
  return Fred;

var echo= returnValue(Mary);
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
<script src="script.js"></script>

2 Answers

Brodey Newman
Brodey Newman
10,962 Points

Hey Gena!

So to explain what's going on here..

You are creating a function that takes in a value as a parameter like below:

function returnValue(val) {
     return val;

Since you are returning the value inside of that function, we want a way to store that value which is returned from that function, inside of a variable. Below is what they are expecting.

var echo = returnValue('Hello!');

So now, if you console.log 'echo', you will see 'Hello!' logged to the console!

Below is what your code should look like to pass this challenge.

function returnValue(val) {
     return val;

var echo = returnValue('Hello!');

I hope this helps! :)

Gyorgy Andorka
Gyorgy Andorka
13,811 Points

Hi! When you call the function, you should pass in a string value as an argument, but you've passed in a variable which is not defined anywhere (the program does not know where to look for the value of Mary, this leads to an error). Note: in JavaScript (and most other languages) the convention is to start variable names with a lowercased letter.