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

Shreemangal Sethi
Shreemangal Sethi
Full Stack JavaScript Techdegree Student 15,552 Points

Problem with understanding the Return.

The question in one of the challenges asks to create a function named returnValue and pass it any argument and return immediately. To which my response is

function returnValue(drink){ return drink; } This passes the test

Then when the challenge asks to create a variable named echo and store the result of calling the function returnValue. To this my response is

function returnValue(drink){ var echo = alert('Please get me a ' + drink); return echo;}


At this stage the it says the 1st Task is not passing. I am not able to understand where am i going wrong. Is there something wrong that i am doing in understanding the basics. Please help.

function returnValue(drink){
  return drink;

  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
<script src="script.js"></script>

1 Answer

Antti Lylander
Antti Lylander
9,686 Points

for task 2, do exactly what the instructions say and nothing else:

Challenge Task 2 of 2 After your newly created returnValue function, create a new variable named echo. Set the value of echo to be the results from calling the returnValue function. When you call the returnValue function, make sure to pass in any string you'd like for the parameter.

I bolded some important words there. You only need one short line for the second task. It is much simpler than what you have written. First off, do not declare the function again. You need to declare a variable and assign a value to it.

Hope this helps. The solution is not that difficult. :)