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

confused by where var echo should go

can someone explain what this task is asking

script.js
function returnValue(Fred) {
  return Fred;

}
var echo= returnValue(Mary);
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

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! :)

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.