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

Christopher Leveston
Christopher Leveston
2,987 Points

Not quite sure the question they're asking. Stuck on adding the string.

I'm not sure if I am getting what the question is asking for. I was able to display the value that I want in the function's parameters by calling it, but I am kinda confused on adding the string part. Here is what I got.

script.js
function returnValue(number,string) {
  return number;
  return string;
}
var echo = returnValue(10, "the string");
document.write(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

I'm surprised the first task passes. According to the instructions you are to have a single parameter. Remove all code related to number and the document.write statement and you should pass.

Christopher Leveston
Christopher Leveston
2,987 Points

Oh wow! Thanks a bunch. During the first task, I assigned just one parameter to the function, but when I got to the next task, that's when I added all that extra nonsense LOL. While I was waiting on a response, it clicked that adding a second return wouldn't work because the program will only see the first return and not the 'return string', so I knew that was wrong. Thanks for the response!