const phones = [
{ p: '9171857450', c: 1 },
{ p: '9880735438', c: 10 },
{ p: '9880735439', c: 100 },
{ p: '9880735779', c: 2 },
{ p: '9170997305', c: 2 },
{ p: '9170997493', c: 2 },
{ p: '9880634879', c: 5 },
{ p: '9170996154', c: 1 },
{ p: '9880728447', c: 1 },
];
const chancesTotal = phones.reduce((acc, { c }) => acc + c, 0);
const selected = Math.floor(Math.random() * chancesTotal);
let phone;
for (let i = 0, sum = 0; i < phones.length; i++) {
sum += phones[i].c;
if (selected < sum) {
phone = phones[i].p;
break;
}
}
const randomUrl = `https://wa.me/${phone}?text=Привет!%20Пришлите%20мне%20цены%20на%20рыбку!`;