JavaScript JavaScript Basics Creating Reusable Code with Functions Passing an Argument to a Function

Fabrice Innocent
Fabrice Innocent
Full Stack JavaScript Techdegree Student 9,342 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

Nils Kriedner
Nils Kriedner
Front End Web Development Techdegree Student 19,062 Points

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. :-)