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

James Cobbett
James Cobbett
1,468 Points

I have been struggling on this code for a week, but nI cannot seem to get the answer. Any Advice? Question 2 Im stuck on

I have been struggling on this code for a week, but nI cannot seem to get the answer. Any Advice? Question 2 Im stuck on

script.js
function returnValue() {
  var echo = returnValue;
  returnValue(echo);
}
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>

1 Answer

Steven Parker
Steven Parker
231,275 Points

It looks like you confused the two tasks. In task 1, you create a simple function that returns its argument. Once you pass that task, make no changes to that function!

In task 2, you will add code outside (after) the function in which you will create the variable "echo" and assign it by calling the task 1 function.

I'll bet you can get now that you know the tasks are completely separate (except for the call).