kush
New Coder
there is around 300 users who watched video multiple times so i want to know how many users are watched the last video i just want to know how to get the final calculated value outside of async.each? i need to return inside an object
Code:
function(totaluser,callback)
{
let cnt=0;
var response={}
async.each(totaluser.userByLearner,function(item,callback){
that.courseRegister.findOne({userId:item},{introVideo:1},function(err,data){
//console.log("##############################",data.introVideo[data.introVideo.length-1]);
if(data.introVideo[data.introVideo.length-1])
{
//console.log(data.introVideo[data.introVideo.length-1])
//userList.push(data.introVideo[data.introVideo.length-1]);
cnt++
}
})
},function(){
console.log("----------------------------",item)
})
return responsedata={
activeuser:cnt
}
}