On about line 18, make the anonymous function with the code 'window.didExecute = true' execute.
var anonymousFunction = function(){};
(function(){window.didExecute=true;})
doesn't work, why?
Because the function is never executed. Use an immediately invoked function expression:
(function(){window.didExecute=true;})();
The () at the end is what actually makes it a function call, resulting in the body of the function executing.
If you weren't using anonymous functions, your code would be the same as doing:
function foo() {
window.didExecute = true;
}
Then never calling foo().
()after your function. ((function(){window.didExecute=true;})()). Or remove the()around it.