JSFiddle - React, Tailwind, and code Playground

by blineberry

HTML

<!-- A: 90 - 100
B: 80 - 90
C: 70 - 80
D: 60 - 70
F: 0 - 60

mean = 50
-->
<fieldset>
    <legend>Grade Scale</legend>
    <label>A: <input id="a_low" type="number" value="90"/>&ndash;<input id="a_high" type="number" value="100"/></label><br />
    <label>B: <input id="b_low" type="number" value="80"/>&ndash;<input id="b_high" type="number" value="89"/></label><br />
    <label>C: <input id="c_low" type="number" value="70"/>&ndash;<input id="c_high" type="number" value="79"/></label><br />
    <label>D: <input id="d_low" type="number" value="60"/>&ndash;<input id="d_high" type="number" value="69"/></label><br />
    <label>F: <input id="f_low" type="number" value="0"/>&ndash;<input id="f_high" type="number" value="59"/></label>
</fieldset><br />
<label>Number of Students: <input id="student-count" type="number" min="1" value="100" /></label><br /><br />
<button id="calculate">GIVE ME SOME EFFIN' GRADES</button>

<div id="results"></div>

JavaScript

function getSomeEffinGrades() {
    var studentCount = $('#student-count').val();

    var gradeScale = {
        a: {
            low: $('#a_low').val(),
            high: $('#a_high').val()
        },
        b: {
            low: $('#b_low').val(),
            high: $('#b_high').val()
        },
        c: {
            low: $('#c_low').val(),
            high: $('#c_high').val()
        },
        d: {
            low: $('#d_low').val(),
            high: $('#d_high').val()
        },
        f: {
            low: $('#f_low').val(),
            high: $('#f_high').val()
        }
    };
    var cSplit = (gradeScale.c.high - gradeScale.c.low) / 2;

    var averageGradeDiff = ((gradeScale.a.high - gradeScale.a.low) + (gradeScale.b.high - gradeScale.b.low) + (gradeScale.c.high - gradeScale.c.low) + (gradeScale.d.high - gradeScale.d.low)) / 4;
    gradeScale.horrible.low = gradeScale.f.low;
    gradeScale.f.low -= Math.floor(averageGradeDiff);
    gradeScale.horrible.high = gradeScale.f.low - 1;

    var perfect = [];
    var a = [];
    var b = [];
    var cHigh = [];
    var cLow = [];
    var d = [];
    var f = [];
    var horrible = [];
    var iCount = 0;

    // Calculate Perfects
    for (iCount; iCount < Math.floor(studentCount * 0.0013); iCount++) {
        perfect.push(gradeScale.a.high);
    }
    // Calculate As
    for (iCount; iCount < Math.floor(studentCount * 0.0215); iCount++) {
        a.push(getRandomInt(gradeScale.a.low, gradeScale.a.high - 1));
    }
    // Calculate Bs
    for (iCount; iCount < Math.floor(studentCount * 0.1359); iCount++) {
        b.push(getRandomInt(gradeScale.b.low, gradeScale.b.high));
    }
    // Calculate CHighs
    for (iCount; iCount < Math.floor(studentCount * 0.3413); iCount++) {
        cHigh.push(getRandomInt(gradeScale.c.high - cSplit, gradeScale.c.high));
    }
    // Calculate CLows
    for (iCount; iCount < Math.floor(studentCount * 0.3413); iCount++) {
        cLow.push(getRandomInt(gradeScale.c.low,...