Skip to content

Instantly share code, notes, and snippets.

@bwilkins
Created February 1, 2012 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bwilkins/1715027 to your computer and use it in GitHub Desktop.
Save bwilkins/1715027 to your computer and use it in GitHub Desktop.
Hopefully faster/better version of previous tax function
function tax(total) {
var accum = 0;
var tiers = [
0,
14000,
48000,
70000,
]
if (total <= tiers[1])
return total*0.1254
accum += tiers[1]*0.1254
total -= tiers[1]
var accumtier2 = tiers[2]-tiers[1]
if (total <= accumtier2)
return accum + total*0.1954
accum += accumtier2*0.1954
total -= accumtier2
var accumtier3 = tiers[3]-accumtier2
if (total <= accumtier3)
return accum + total*0.3204
accum += accumtier3*0.3204
total -= accumtier3
accum += total*0.3504
return accum
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment