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 trialRogean Edwards
7,101 PointsI'm having a bit of trouble with the syntax. I thought i got the concept but now i'm not sure. Help!
STAGE 1 - Worked fine
var anonymousFunction = function () {
}
STAGE 2- Did not execute
var anonymousFunction = function () {
(window.execute = true);}()
1 Answer
Erik McClintock
45,783 PointsRogean,
There seems to be a slight bit of a misunderstanding here. You've taken the function that they have on line 18 and added it into your anonymous function on line 16. In task 2, they are not asking you to do this, although it is stated in a somewhat confusing manner. They actually want you to make the anonymous function on line 18 execute itself, which you do by adding the open and close parenthesis to the end of the function (as it appears you have attempted, but make sure you've got your semi-colon at the end and that you're not repositioning the code!).
You have this:
var anonymousFunction = function () {
(window.execute = true);}()
You want this:
var anonymousFunction = function(){};
(function () {
window.didExecute = true;
})();
Do you see the difference? You've got the right idea, and are getting a grasp on the syntax for sure, it's just that the challenge is worded in a kind of confusing manner, and your code was in slightly the wrong place :)
Hope this helps!
Erik
Erik McClintock
45,783 PointsErik McClintock
45,783 PointsRogean,
I've edited your code so that it's posted correctly using Markdown. See this post for more information on how to do this for future posts!
Erik