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 trialnicholas maddren
12,793 PointsChallenge Makes No Sense To Me
The coding doesn't seem to be the problem. It's what they are asking of me that is the problem. For example the challenge is:
Set the variable 'anonymousFunction' to be an anonymous function without any code to be executed.
So I this code:
var anonymousFunction = function() {});
It's an anonymous function isn't it?
Thanks
4 Answers
Nathaniel Miller
8,802 PointsIf you haven't figured this out yet, maybe this will help:
http://markdalgleish.com/2011/03/self-executing-anonymous-functions/
As the article says in that link, "Those two little brackets cause everything contained in the preceding parentheses to be executed immediately."
So the answer is to add () to line 20, immediately before the ;
Aaron Graham
18,033 PointsIt looks like you have an extra ")". Try this:
var anonymousFunction = function() {};
nicholas maddren
12,793 PointsThanks so I managed the first task but now they want me to execute it. Here is my code:
var anonymousFunction = (function () { window.didExecute=true })();
For some reason it isn't passing. As I am dyslexic I'm having real hard time understanding what they want me to do. It would be great if they went a little more in-depth.
Aaron Graham
18,033 PointsI think they want you to execute it using the variable you assigned it to. Like this: anonymousFunction();
The way you have it written would execute the function and assign the return value to anonymousFunction. This can be very handy (if you are interested, try a google search for javascript closures), but with your current code, you are essentially just assigning anonymousFunction a value of "undefined".
Brian van Vlymen
12,637 PointsBrian van Vlymen
12,637 Pointswow it was such a great article! I think I get it .