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

Ramone Adams
seal-mask
.a{fill-rule:evenodd;}techdegree
Ramone Adams
Front End Web Development Techdegree Student 8,693 Points

Not sure if it's a bug but it's telling me that I'm not storing my return value into my variable which I'm sure I am

Is this not the correct way to input my variable into my function?

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

Tobias Helmrich
Tobias Helmrich
31,602 Points

Hey Ramone,

you're storing the string "mama" inside the variable echo (not the argument mama, if you would like to use the argument you shouldn't write it in quotes). However you should store the return value of the function in the variable echo after the function.

Like that:

function returnValue(arg) {
  return arg;
}

var echo = returnValue("Hello");

I hope that helps, if you have any other questions feel free to ask! :)