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

Fabrice Innocent
seal-mask
.a{fill-rule:evenodd;}techdegree
Fabrice Innocent
Full Stack JavaScript Techdegree Student 9,715 Points

So for the second part of this challenge..I can't seem to grasp what it is I'm missing/doing wrong Any help?

I'm not understanding why i'm getting this particular error message

script.js
function returnValue(lit) {
    var value = lit;
  return value;
 }

function returnValue(peace) {
    var echo = returnValue(peace);
  return echo;
  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

Hi Fabrice,

for the first part of the code challenge you can make the code easier: You don't need to create a variable and reassign the parameter/argument to the variable. You can just return the the argument like this:

function returnValue(number) {
  return number;
}

In the second part of the challenge you then need to create a variable named echo (OUTSIDE of the function) and assign the value with the function. For the function parameter you can pass any number or string.

Makes sense?

Try a bit and if you still need help feel free to ask again!

Happy coding,

Nils

PS: You can upvote my post and/or mark as "best answer" (at the bottom of my post) if it helped you. :-)

Very welcome! :-)