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 trialChristopher Flores
6,898 PointsPlease help me understand...
I've tried several things, even putting the 'greetings' parameter into the echo variable, but it's not working out. That, and I don't really understand the question. The way it's worded is screwing me up but I can't explain why. And I believe I've tried writing - return echo + greeting; but that isn't working either.
function returnValue(greeting) {
var echo = "Hi echo";
return echo;
}
alert(returnValue("Hi echo"));
<!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>
1 Answer
Valentin Weiss
9,749 PointsHi Christopher
Since you need to assign echo
variable to the return value of the returnValue
function, the echo
variable should be initialized after the function definition, not in the function itself. You can do this as follows: var echo = returnValue("some string");
Christopher Flores
6,898 PointsChristopher Flores
6,898 PointsThanks Valentin
I guess I wasn't understanding that the question was asking you to put the variable outside of the initial function's code block.
Appreciate the help :)