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!
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 trialJason Larkin
13,970 PointsAnonymous Function Problem
The code challenge calls for making the anonymous function variable not execute in the first challenge, but wants you to make it execute in the second. Can anybody please help?
<script>
var anonymousFunction = function () {};
(function () { return
window.didExecute = true;
});
</script>
3 Answers

Jason Anello
Courses Plus Student 94,610 PointsHi Jason,
The 1st line of code is for task 1 only and doesn't have anything to do with task 2.
The code of interest for task 2 is the following:
(function () {
window.didExecute = true;
});
So the challenge wants you to make that anonymous function execute. The way you make a function execute is by adding parentheses at the end right before the semi-colon.

lata sharma
iOS Development Techdegree Student 5,292 PointsThanks Jason! I had finally figured it out after lot of frustration!

Jason Anello
Courses Plus Student 94,610 PointsGlad you figured it out!

Daniel Quaidoo
23,413 PointsYou're calling the anonymous function wrongly. Review the video.
Jason Larkin
13,970 PointsI've watched it seven times and I still don't see it.
Jason Larkin
13,970 PointsJason Larkin
13,970 PointsThanks Jason. I was on the verge of figuring it out, but you helped immensely.
lata sharma
iOS Development Techdegree Student 5,292 Pointslata sharma
iOS Development Techdegree Student 5,292 PointsJason - I added the parenthesis...but it is still working? what am I doing wrong?
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsHi lata,
If you put them right before the semi-colon then it should work.
Post the code that you're trying if it's still not working for you.