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

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,253 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."