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 trialmarcus fields
2,641 PointsI've been on this problem for days
What am I doing wrong
Function returnValue(money) { return money} Var echo = money; returnValue("here's ya cash");
Help ya boy out!!
function returnValue(money){return money}
<!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
Steven Parker
231,236 PointsYou were pretty close.
But you don't have a variable named "money", that's just the parameter name in your function. You wouldn't need a variable anyway, you just need to assign echo directly with the result of calling your function. Also, remember that JavaScript is case-sensitive, so "var" must be spelled in all lower case:
var echo = returnValue("here's ya cash");
Benjamin Larson
34,055 PointsThe instructions say: Set the value of echo to be the results from calling the returnValue
function.
When calling the returnValue
function, like this:
returnValue("My String");
it will automatically return the value, because of the return statement you declared in the function. In the above example however, you aren't doing anything to "catch" what it's returning or to save it. It's being returned but since nothing is catching it, it effectively disappears.
So you want to assign the result of calling that function into a new variable--in this case, a variable called echo
.
var echo = returnValue("MyString");
If a function returns a value but no variable is there to catch it, does it really return?
marcus fields
2,641 PointsI appreciate it fam... does the shit get more complicated? Or does it ease up
Benjamin Larson
34,055 PointsWell...it will certainly get harder. At times a lot harder. But at that same time, things that were once hard become easy and you don't even have to think about them anymore. Learning the fundamentals of any language is daunting at first and you'll probably have times where you feel like you're getting a good handle on things for awhile but then a new concept will be introduced that makes you feel lost all over again.
It's all a matter of how much time and practice you want to commit to it, but there's lots of people here willing to help along the way.
Evgeniia Mas
4,452 PointsIf you really want to return same money, just add semicolon like this return money;
marcus fields
2,641 Pointsmarcus fields
2,641 PointsThanks for breaking that down fam... this shit was whipping my ass