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

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,497 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