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

Toni Hammond
Toni Hammond
13,730 Points

help! I need to modify the return value in Task #2 in Javascript, I have been stuck for hours what am i doing wrong guys

not sure what to do next :(

function returnValue(beans) { 
  return "beans"; 

var echo = returnValue('beans');
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
<script src="script.js"></script>

2 Answers

This worked for me

function returnValue(value){ return value; } var echo = returnValue(1);

Steven Parker
Steven Parker
230,248 Points

Task 2 says "Modify the returnValue function to accept one argument named value." But this function's argument is named "beans" instead.

Then, task 3 says "Finally, from the returnValue function return the value passed in." But this function is returning the constant string "beans" instead of the passed argument.

Fix those and you should pass the challenge. And it doesn't look like you need to create a new "echo" variable or call the function for this challenge.

Steven Parker
Steven Parker
230,248 Points

Toni Hammond — Glad to help. You can mark a question solved by choosing a "best answer".
Happy coding!