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

Christopher Flores
Christopher Flores
6,592 Points

Please help me understand...

I've tried several things, even putting the 'greetings' parameter into the echo variable, but it's not working out. That, and I don't really understand the question. The way it's worded is screwing me up but I can't explain why. And I believe I've tried writing - return echo + greeting; but that isn't working either.

function returnValue(greeting) {
  var echo = "Hi echo";
  return echo;
alert(returnValue("Hi echo"));
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
<script src="script.js"></script>

1 Answer

Valentin Weiss
Valentin Weiss
9,749 Points

Hi Christopher Since you need to assign echo variable to the return value of the returnValue function, the echo variable should be initialized after the function definition, not in the function itself. You can do this as follows: var echo = returnValue("some string");

Christopher Flores
Christopher Flores
6,592 Points

Thanks Valentin

I guess I wasn't understanding that the question was asking you to put the variable outside of the initial function's code block.

Appreciate the help :)