JSFiddle - React, Tailwind, and code Playground
by Scott Kaye
JavaScript
function rand(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
var times = 100000;
var success = 0;
var j = times;
while (j--) {
var sum = 0;
var i = 4;
while (i--) sum += rand(0, 6);
if (sum <= 7) success++;
}
console.clear();
console.log(success / times * 100 + "% chance of rolling 7 or lower");