JSFiddle - React, Tailwind, and code Playground
by jfriend00
HTML
<div id="result"></div>
CSS
#result {font-family: "Courier New";}
JavaScript
var rand5 = function() {
return(Math.floor(Math.random() * 5) + 1);
};
// Return a sample distribution over MAX times.
var testRand5 = function(dist, max) {
if (!dist) { dist = {}; }
if (!max) { max = 5000000; }
for (var i=0; i<max; i++) {
var r = rand5();
dist[r] = (dist[r] || 0) + 1;
}
return dist;
};
var items = testRand5();
for (var i in items) {
$("#result").append(i + ": " + items[i] + "<br>");
}