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

Travis White
Travis White
749 Points

Task 1 is no longer passing

I need to create a variable to store the results from calling the function.

But when I do that, I need to change the return to return the variable, rather than just the parameter (task 1).

And when I do that - it says Task 1 no longer passes because the code differed between 1 and 2.

But doesn't if have to if I'm adding the variable in?

script.js
function returnValue(month) {
  var echo = month
  return echo + ' is my birthday.';
}
console.log ( returnValue('April') );
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

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

don't change the code for previous tasks unless it explicitly asks you to. the variable to store the return of the function does not go in the function, it goes outside. when you call the function it will return its value and that is stored in the variable. so var myVar = myFunc() would result in myVar holding the return value of myFunc.