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

Seth Johnson
Seth Johnson
15,200 Points

Need help figuring out the "Passing an Argument to a Function" Code Challenge.

I don't know if I simply keep misunderstanding the instructions, but I cannot figure out step 2 of this challenge, particularly the "Set the value of echo to be the results from calling the returnValue function" portion of it. Everything I try keeps telling me I haven't stored a return value for the "echo" variable.

script.js
function returnValue( instructions ) {
  var echo = instructions;
  return instructions;
}
returnValue("hello");
index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

2 Answers

Steven Parker
Steven Parker
231,236 Points

You're close, but the function itself should be left as it was when you passed task 1. All of the task 2 instructions are to be performed outside of the function.

Your call is good, but the declaration and assignment of "echo" should be down there also.

Seth Johnson
Seth Johnson
15,200 Points

Still having a lot of difficulty figuring this one out. I did get it done and got the checkmark and what-have-you, but I feel like it was only through sheer dumb luck.

Steven Parker
Steven Parker
231,236 Points

It's not uncommon for it to take a bit of exposure to something new to "sink in". You might need to just forge ahead for a little bit until you have an "Aha!" moment.