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

Jacqueline Grubb
Jacqueline Grubb
2,343 Points

in this challenge, I'm being asked to store a function parameter in a variable called "echo" and I can't make it work?

I don't understand what I'm doing wrong -- I'm supposed to write a function that receives "My argument" as the value and then passes that to a variable called "echo". Below is what I wrote. I'm so confused about what I'm doing?? thanks in advance for the help!

function returnValue (value1) {
  var echo = value1;
  return value1;
}
returnValue ("My Argument");

3 Answers

Jacqueline Grubb
Jacqueline Grubb
2,343 Points

Found an answer by Matt F. in response to someone else's previous question -- Thank you Matt!.

The answer is to place the variable name "echo" in front of returnValue() rather than up in the function itself.

var echo = returnValue ("My Argument");

Thanks!

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,028 Points

Hi Jacqueline.

function returnValue (value1) {
  var echo = value1;
  return value1;
}
returnValue ("My Argument");

I just put this exact same code into my code challenge and as I suspected, it works! You've nailed it! So try again and it should work.

You've passed the a parameter into your function and called it correctly at the very end. :-)

Jacqueline Grubb
Jacqueline Grubb
2,343 Points

unfortunately, something is still wrong because I'm stuck in a challenge and I can't move forward until I figure out what I'm being asked...Ugh! It still says "Bummer! Hmmm. It doesn't look like you're storing the returned value in the echo variable."