mturk_ops.block = function(callback){ mongodb.collection(collectionName, function(err, collection){ collection.distinct('workerId',function(err,result){ var result1 = []; console.log(result.length); for(var i=0; i< result.length;i++){ console.log(result[i]); result1[result[i]] = collection.count({ 'workerId':result[i], "judgementStat" : "majority" },function(err, count){
}
Here I am trying to print 'result1', but its always a printable array with an undefined value. 'result1' is an array that is assigned outside the scope of the callback function.
source share