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

Roscoe Coney
Roscoe Coney
13,124 Points

Im DROWNING in this question!! plz help

QUESTION:

Now that you've created the returnValue function, call it, by passing it a literal string value -- a series of characters in quote marks like this: 'My argument'. Store the results of the function in a variable named echo.

I have below:

function returnValue (car) {

  var echo = "My argument"

return (car)

}
Shilpa K
Shilpa K
12,722 Points

If you can correct your markup for it to be easier to read, that would be helpful. But already I can see that you need to put an " = " to assign your variable var echo, not " - "

2 Answers

Matthew Ong
Matthew Ong
6,041 Points

You need to return the argument passed into the function, not a defined string. You are also missing a few semicolons. This should work:

function returnValue (car) {

 return (car);

 }
var echo = returnValue('hello');
Roscoe Coney
Roscoe Coney
13,124 Points

I tried that and I received the following error message

Bummer! To call a function type its name and a pair of parentheses like these returnValue('hello').

Matthew Ong
Matthew Ong
6,041 Points

Oh it wants you to actually call the function. I've updated my answer, try it now.

Roscoe Coney
Roscoe Coney
13,124 Points

Perfect!! Thanks, I see what I did wrong!

Richard Duncan
Richard Duncan
5,568 Points

Roscoe Coney Hi! If you're satisfied with the answer it's good practice to mark it as 'best answer' to encourage help in the future and also should any student struggle with this themselves they will have a reference to it :)

function returnValue(a){ return a;} var echo = "returnValue("a")";

i keep getting it wrong

You doing it wrong totally. Advise you to watch the video over and over.

function returnValue(a){ return (a); }

var echo = returnValue("Much to learn still have.");