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

Scott Duncan
Scott Duncan
2,287 Points

Im stuck with this

"Set the value of echo to be the results from calling the returnValue function. When you call the returnValue function, make sure to pass in any string you'd like for the parameter. "

script.js
function returnValue("pa") {
  return pa;
}

var echo = returnValue("hi");
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

When you define a function, never put quotes around any parameter names (or around any variable names in general). This must have changed after you passed task 1. You also don't want to make any changes to the task 1 function during task 2.

Your other task 2 work looks good, so fix that and you'll pass.

Scott Duncan
Scott Duncan
2,287 Points

got it thanks steven. the whole things still pretty confusing

I found it confusing to begin with. Just keep going and trust that if you do you will eventually get it. Seems like the confusion is about parameters vs arguments which definitely confused me to begin with.

When you declare the function: function returnValue(value) { return value; }

Here value in the brackets is a parameter.

When you call the function: returnValue("Hi");

Hi is now an argument being passed to the function.

Arguments can be string values, numbers etc (i.e. in quotation marks) parameters can't be string values (at least as far as I am aware).