var r=[{'name':'a','a':2},{'name':'d','a':1},{'name':'z','a':3},{'name':'l','a':0}];
sumOfWeights=lodash.sumBy(r, 'a');
randomWeight = lodash.random(1, sumOfWeights);
i=0;
while(randomWeight<=0){
value=r[i];
randomWeight = randomWeight - value.a;
i++;
if (randomWeight<=0){
console.log(value);
break;
}
}