JSFiddle - React, Tailwind, and code Playground
HTML
<div id="out"></div>
JavaScript
var nums = [];
for(var i = 0 ; i < 10000; i++) {
var outOfBoundsChance = .2;
var num = 0;
if (Math.random() <= outOfBoundsChance) {
num = getRandomInt(1, 100);
} else {
num = getRandomInt(40, 60);
}
nums.push(num);
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
$("#out").html(nums.reduce(function(p,c){ return p + ((c > 60) || (c < 40) ? 1 : 0); },0)/nums.length);