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 trialjames mchugh
6,234 Pointsstuck on this
I've tried every combination I can think of
function returnValue(length) {
return length;
var echo = (returnValue);
returnValue(echo + unit);
}
console.log( echo( 20, 'sq ft') )
<!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
Ben Reynolds
35,170 PointsThe echo variable should be declared after the returnValue function, not inside it. echo's value should be the result of calling returnValue with any string passed in.
Ashley, your code works on your test html page because it's valid javascript, i.e. no syntax errors, it's just not performing the operations in the order the challenge is expecting.
Ashley Elson
Front End Web Development Techdegree Student 5,972 Pointsfunction returnValue(e) {
var echo = e;
return echo;
}
console.log(returnValue('hi'));
This SHOULD work but on the challenge its not saying it works however when I try it on a HTML page it works fine so I'm not entirely sure
Ashley Elson
Front End Web Development Techdegree Student 5,972 PointsAshley Elson
Front End Web Development Techdegree Student 5,972 PointsOO I get it, you're right my bad.
james mchugh
6,234 Pointsjames mchugh
6,234 PointsI'm still confused. I declared the variable echo outside the function, and I tried to return the returnValue, but it's giving me an error message. I'm really confused. I've posted a new one with my last attempt. Thanks for your help Ben, I'm gradually understanding.