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

Martin Bornman
Martin Bornman
Courses Plus Student 12,662 Points


I am totally stuck with this problem.Can someone help please??

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

3 Answers

Steven Parker
Steven Parker
221,296 Points

I'm guessing you passed Task 1 and started on Task 2, right? Here's a few hints:

  • the challenge said "After your function...", but you started to put it inside your function
  • remember to use the word var when declaring a new variable
  • assign your new variable with the result of calling your function (the function name with ()'s after it)
  • remember to give your function a string parameter (between the ()'s)
Arturo Alviar
Arturo Alviar
15,739 Points

Hi Martin,
Your function is correct but the echo declaration is in the wrong place. Here is how should look like:

function returnValue(something){
  return something
//Set the value of echo to be the results from calling the returnValue function.
var echo = returnValue("Hello!");

Hope this helps!

OK this one is a bit of brain twister! Let's break it down. Step 1

_Create a function named returnValue that accepts a single argument (you can name it anything), then immediately returns that argument. _

so we have

   function returnValue(myValue) {
  return myValue;

//creates a function that accepts a value then returns that value.

next we have to _After your 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 in any string you'd like for the parameter. _

   function returnValue(myValue) {
  return myValue;

//call the function then pass a string


//this call the function and passes in "Bob" -> note the "" to make it a string.

Hope this helps