let a = [{id: 1, int: 300}, {id: 333, int: 1000}, {id: 672, int: 5000}];
let sum = 0;
for (let i = 0; i < a.length; i++) {
sum += a[i].int;
}
let rand = Math.floor(Math.random() * sum);
let i = 0;
for (let s = a[0].int; s <= rand; s += a[i].int) {
i++;
}
console.log(a[i].id);