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 trialVal Ki
1,997 PointsPlease help!
I keep running into an error when I run this code. Please help.
function returnValue(age) {
var echo = 'hi there';
return age;
}
returnValue('15');
<!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>
Val Ki
1,997 PointsI keep running into this:
Bummer! Hmmm. It doesn't look like you're storing the returned value in the echo
variable.
1 Answer
Rich Donnellan
Treehouse Moderator 27,708 PointsHi, Val!
You're so close! It's all in the wording:
After your newly created returnValue function, create a new variable named echo.
Extract your variable declaration to be outside of the function, and assign your last line to it (e.g. var someVar = functionCall(arg);
). This effectively stores the return value in your variable for later use.
Hope this hint helps!
Val Ki
1,997 PointsHi Rich,
I think I am trying your way but I'm still getting an error. Could you write out the code?
Rich Donnellan
Treehouse Moderator 27,708 PointsSure thing.
Spoiler
function returnValue(age) {
return age;
}
var echo = returnValue('15');
Andrei Duhanes
14,155 PointsAndrei Duhanes
14,155 PointsHi .. What is the error?