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

David Dong
David Dong
5,593 Points

What does this mean?

What does the question mean? 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.

script.js
function returnValue(oh) {
  return oh;
}
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

Echo is what the challenge wants the name of the variable to be. Echo isn't a function. Echo is placed outside of the function and you want to set the variable equal to the function name. You can see the below QA for more info on this challenge.

https://teamtreehouse.com/community/after-your-newly-created-returnvalue-function-create-a-new-variable-named-echo-need-help-with-this-challenge-task

I'm not sure what part of the challenge you're not sure of, but I'll assume it's the whole thing. So a function basically sets up code that does something. Let's say we make a battle bot in code. So the battle bot has a flame thrower and a rotating blade o' death to destroy other battle bots...that's the battle bot's function: to destroy other battle bots using its attacks.

However, let's say we made our battle bot without any directions. If we want to remember how to recreate the battle bot we can store it back into our brain through using our memory (which is automatic for most of us thankfully!) or write it down. Return works like a way of remembering how to make the battle bot, and return is just one way a program takes the contents of the function, in your case, "oh" and returns that, in this case, to the program's memory.

The battle bot example might be:

function robot (battlebot) {
return battlebot;
}

As a note, I barely understand this stuff myself, so I might be a bit off....but hopefully my response helps some.

David Dong
David Dong
5,593 Points

I know that part of it, but what I don't understand is the question. Where do I put the 'echo' function? What do I put in it?