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 trialNazaam Kutisha
7,667 PointsChallenge question #2
Question: On about line 18, make the anonymous function with the code 'window.didExecute = true' execute.
My response:
var anonymousFunction = (function(){
window.didExecute = true;})
</script> ```
2 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Nazaam,
The code from task1 and 2 are two separate things and it looks like you've tried to combine them.
Task1 code would have been var anonymousFunction = function() {};
An anonymous function that doesn't do anything has been assigned to the variable anonymousFunction
Separately they want you to execute the anonymous function that begins on line 18. To do that you add parentheses at the end of it.
(function () {
window.didExecute = true;
})();
This is an immediately-invoked function expression
Nazaam Kutisha
7,667 PointsHi Jason,
I tried it this way first, I must of had too few parentheses.
Many Thanks,