JSFiddle - React, Tailwind, and code Playground
JavaScript
function generatePool (count, luckyNumbers) {
var arr = [], i, j;
for (i = 1; i <= count; i++) {
if (luckyNumbers[i]) {
for (j = 0; j < luckyNumbers[i]; j++) {
arr.push(i);
}
} else {
arr.push(i);
}
}
return arr;
}
function randomNumber (pool) {
return pool[ Math.floor(Math.random() * pool.length) ];
}
//-- usage
var luckyNumbers = {};
luckyNumbers[13] = 10;
luckyNumbers[25] = 100;
var pool = generatePool(300, luckyNumbers);
alert(randomNumber(pool));