function random(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + 1
}
let arrRandom = [];
for (let i = 0; i < 1000; i++) {
arrRandom.push(random(1, 5))
}
console.log(arrRandom.sort());
let countObj = {};
for (i = 0; i <= arrRandom.length - 1; i++) {
let v = arrRandom[i];
if (countObj[v]) {
countObj[v]++;
} else {
countObj[v] = 1;
}
}
console.log(countObj); //{ '2': 2, '3': 1, '5': 4, '11': 2 }