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

I'm stuck on this function challenge in Javascript Basics. :( After creating the var echo, I keep getting syntax error.

Can anyone help?

script.js
function returnValue() {
  return what;
}
var echo = what
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

You're close, just need to move some things around.

function returnValue() {
  return what;
}
var echo = what
returnValue( "Hi!");

You're going to want to pass a variable to the function as a variable like

function name(variable)

and return that variable. The next part wants you to pass a string to your function (and have it returned) then assign that returned valued to your echo variable.

var variable = func("some string I pass ing")

Thanks. Hmmm... it worked eventually. Still getting used to this.