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

Ahkeem Lang
Ahkeem Lang
16,358 Points

I'm stuck ha!

I guess I'm not understanding the question fully. How can the variable contain the result of the function? I created the var echo = sound; but.. what's next?!

Dale Severude
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,350 Points

Hi Ahkeem, The variable should call the function with an input string you create.

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

2 Answers

jason chan
jason chan
31,009 Points
//create function argument pass in arg
function returnValue(arg) {
  return arg;
}
// create a variable echo, call the function returnValue
var echo = returnValue('Red Fox');
Ahkeem Lang
Ahkeem Lang
16,358 Points

Thanks for the help everyone!!

Ahkeem Lang
Ahkeem Lang
16,358 Points

I'm relatively new to programming but I'm making some good Hedge way, right now I'm taking the rails track. I enjoy back end engineering and I'm attending a coding school in May for back end engineering, but any recommendations for other courses on here I should take?!