I don't understand where is the problem, I've read several questions here, but nothing something like that. I can't use a function to return a promise, I need just tu put all the promises in one array and pass it to the "$.when" function.
var pr = [];
var count = 3; 
while(count--){
   setTimeout(function(){ 
     var def = $.Deferred();
     pr.push(def.promise());    
     console.log('COUNT: '+count); def.resolve(count); 
   }, Math.random()*2000);
}  
$.when.apply($, pr).done(function(d){
     console.log("LOG:",d);
});
Obviously doesn't work because in WHEN pr is empty by that time. How can sort it out?
 
     
    