JSFiddle - React, Tailwind, and code Playground

by Ruchi Samdariya

HTML

<TITLE>1996 U.S. Federal Income Tax Estimator</TITLE>
<SCRIPT>

function TaxBracket(cutoff, percentage, base)
{
    this.cutoff = cutoff;          
    this.percentage = percentage;  
    this.base = base;             
}
function TaxSchedule(b0, b1, b2, b3, b4) 
{  
    this[0] = b0; this[1] = b1; this[2] = b2; this[3] = b3; this[4] = b4;
}


var Schedules = new Object();  


Schedules[0] =  new TaxSchedule(new TaxBracket(263750, .396, 84020.5),
    new TaxBracket(121300, .36, 32738.5), new TaxBracket(58150, .31, 13162),
    new TaxBracket(24000, .28, 3600), new TaxBracket(0, .15, 0));


Schedules[1] = new TaxSchedule(new TaxBracket(263750, .396, 81554),
    new TaxBracket(134500, .36, 35024), new TaxBracket(83050, .31, 19074.5),
    new TaxBracket(32150, .28, 4822.5), new TaxBracket(0, .15, 0));


Schedules[2] = new TaxSchedule(new TaxBracket(263750, .396, 79445),
    new TaxBracket(147700, .36, 37667), new TaxBracket(96900, .31, 21919),
    new TaxBracket(40100, .28, 6015), new TaxBracket(0, .15, 0));


Schedules[3] = new TaxSchedule(new TaxBracket(131875, .396, 39722.5),
    new TaxBracket(73850, .36, 18833.5), new TaxBracket(48450, .31, 10959.5),
    new TaxBracket(20050, .28, 3007.5),  new TaxBracket(0, .15, 0));


var StandardDeductions = new Object();
StandardDeductions[0] = 4000; StandardDeductions[1] = 5900; 
StandardDeductions[2] = 6700; StandardDeductions[3] = 3350;


function compute(f)
{
    var f = document.taxcalc;  

    
    var status = f.status.selectedIndex;

    
    var income = parseFloat(f.income.value);
    if (isNaN(income)) { income = 0; f.income.value = "0"; }
    f.income.value = Math.round(income);
    
    
    var deduction;
    if (f.standard.checked)
        deduction = StandardDeductions[status];
    else {
        deduction = parseFloat(f.deduction.value);
        if (isNaN(deduction)) deduction = 0;
        if (deduction < StandardDeductions[status]) {
            deduction = StandardDeductions[status];
           ...