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 trialCurtis Chadwell
3,150 PointsJust a little confused
I know this is just basic but I feel like I am going back and forth on what its asking.
function returnValue(a){
var echo = 'Curtis' + a;
return echo;
}
document.write(returnValue('Curtis'));
<!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>
2 Answers
Cheo R
37,150 PointsYou're close, just need to move some things around.
function returnValue(a){
var echo = 'Curtis' + a;
return echo;
}
document.write(returnValue('Curtis'));
First delete document.write.
You're going to want to pass a variable to the function as a variable like
function name(variable)
and return that variable. The next part wants you to pass a string to your function (and have it returned) then assign that returned valued to your echo variable.
var variable = func("some string I pass ing")
Curtis Chadwell
3,150 PointsIt makes sense.....the thing that threw me off was when it asked me to make a variable, I was thinking I was still making up another part of the function. Instead I'm storing it outside the function. Thank you!
Cheo R
37,150 PointsYeah, sometimes the hardest part of working on a problem is figuring out what people are actually asking for.