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 trialashique desai
3,662 PointsHow to solve this JavaScript challenge
Need to add a 'var echo' and add the result of the function to it. Plus add a string. I do not know how to do it. Please help me in solving this code challenge. Thanks.
var echo = return str;
function returnValue (str) {
return str;
}
<!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
Steven Parker
231,236 PointsYou can only use return inside a function.
To call a function, you use the function name followed by parentheses enclosing any arguments.
So in this case, instead of return str
you might write returnValue("my string")
ashique desai
3,662 Pointsashique desai
3,662 PointsThanks for your help. Thanks for correcting me with respect to not using "return" outside of function. Tried the solution advised by you. But that solution is not working. I used returnValue(str); also tried returnValue(); but it is not working. Can you suggest any other solution?