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 trialcliffton belcher
2,899 PointsFunction
I don't know what i'm doing wrong in this property can you please help?
function returnValue( upper ) {
var echo = 'My argument';
return upper;
}
<!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>
3 Answers
pi R
12,720 PointsHi cliffton ! Well the challenge asks you to call the function ( to use it ! ) Here you are just modifying it.. you need to write the code outside the function ! I give you a hint : var message = alert("Hello");
Donald Brunais
8,895 PointsThe parameter of the function is is called upper. You then make another variable "var echo = 'My argument';" You then return upper. So all this function is doing is returning the same value that is pasted into it. The variable echo is never being used. As an example say you use the argument "hi", returnValue( "hi" ). Then the return value is "hi".
John Domingo
9,058 PointsIn order to call a function and pass it a parameter, you have to write out the function name followed by a set of parentheses containing the argument you want to pass into it.
I think the task it a bit confusing because it's an oversimplification of what a function is supposed to do (in the sense that the function is not manipulating the argument). It's a function nonetheless and it is meant to echo back what you put into it. Task 1 asked that you create this function. Task 2 is asking you to call the function (which must be done outside of the function, i.e., outside of the curly brackets) so there should be no more modifications of the function code block (i.e., anything inside the curlies).
The argument you should pass to the function (i.e., between the parentheses) is the string "My argument" and consequently the result of the function becomes "My argument" since it's simply echoing back what you entered.
To store the results of the function in a variable, recall that you need to declare the variable using the var keyword and then use the assignment operator (=).