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 trialSHIMRON LAROSE
Courses Plus Student 733 PointsI'm not entirely sure what am doing? How are you supposed to set the value of ECHO to be the results returnValue and a
really confused?
var returnValue = function(blacks) {
var cookies = blacks
return cookies;
}?
<!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>
6 Answers
Steven Parker
231,236 PointsYou have the right code now but in the wrong place
Remember what I said earlier: The new code will come after the function (you seem to have it inside the function here). Also, you seem to have added another definition of "returnValue", but you should only have one.
Don't get confused by Tommy's suggestion, just put your function back to the way you had it when you originally passed task 1. Then put that new line of code after the closing brace of the function.
Steven Parker
231,236 PointsYour function should not end with a question mark.
But otherwise it looks good, and should pass task 1. Then for task 2, after the function, you create a new variable named "echo" and initialize it by calling the function.
You know how to create an initialize a variable because you did it in your function. The only difference this time is calling the function for the value to assign it.
SHIMRON LAROSE
Courses Plus Student 733 PointsNo it's not task one I was referring to I meant task two.
//this is were im confused at not sure how to pass it it don't make sense to me for some reason.
var returnValue = function(blacks) {
var cookies = blacks
return cookies;
var echo = 'Hi';
return echo + 'Hi';
} document.write( returnValue(3,'Hi') );
Steven Parker
231,236 PointsFor task 2, don't make any changes to the function itself.
Leave your function just as it was in task 1. The new code will come after the function. You will create a new variable named "echo" and initialize it by calling the function. Here's a few more hints:
- you will not use any other functions (such as document.write)
- you will only initialize the new variable
- all of task 2 can be done with a single line of code
Tommy Leng
Front End Web Development Techdegree Student 12,417 PointsYou dont have to create a variable inside just return the agreement
var returnValue = function(blacks) { return blacks; }
Steven Parker
231,236 PointsYou're right, and this is certainly more compact. But the other version does satisfy the challenge and this doesn't address the question.
SHIMRON LAROSE
Courses Plus Student 733 Pointsi'm running out of options to what to do?
var returnValue = function(blacks) { var cookies = blacks return cookies; function returnValue(abc) { return abc; } var echo = returnValue('alphabet');
}