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

Raeed Sabree
Raeed Sabree
10,664 Points

after our newly created returnValue function create a new variable named echo.set the value of echo to be the results

from calling the returnValue function when you call the returnValue function make sure to pass any string you;d like for the parameter

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

2 Answers

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there! The key to this is in the first word of your question. After our newly created function...

Here this function doesn't do very much. It accepts a value that we pass to it and then returns it. When it is returned it is immediately assigned to a variable named echo. I modified this so you can see what it looks like if we pass in the value "Jordan".

function returnValue(myValue) {
  return myValue;

var echo = returnValue("Jordan");

Our echo will now have the value "Jordan" assigned to it as that is what was returned by our returnValue function. Hope this clarifies things! :smiley:

Cindy Lea
Cindy Lea
Courses Plus Student 6,485 Points

Try this:

function returnValue(ferociousAnimal) {
  return ferociousAnimal;

var echo = returnValue('Red Fox');

Moderator Edited: Added Markdown to the code for readability in the Forum