I display video ads to my users. I don\'t host these ads by the way; I get them from another company.
When ever an ad is clicked it leaves a cookie in the user\'s b
Passing a Callback to the Interval Function, which in turn updates a counter in the global scope:
var countIntervals = 0,
intervalFunc = function(_callback){
console.log(countIntervals);
if(countIntervals > 5) {
clearInterval(setIntervalVar);
} else {
// do stuff
_callback();
}
};
setIntervalVar = setInterval(intervalFunc.bind(null, function(){
countIntervals++;
}), 500);