JSFiddle - React, Tailwind, and code Playground
JavaScript
const slots = 6;
const randomNums = 10000;
const cov = {}
for( let i = 0; i < randomNums; i++ ){
const random = Math.floor( Math.random() * slots + 1 );
if( cov[random] === undefined ){
cov[random] = { c: 1 }
} else {
cov[random].c++;
}
}
for( let num in cov ){
cov[num].c = 100 / (randomNums / cov[num].c) + ' %';
}
console.log( cov );