Skip to content

Instantly share code, notes, and snippets.

@GitHub30
Created April 22, 2018 13:51
Show Gist options
  • Save GitHub30/57281870266f1147b05f0d114cd7f804 to your computer and use it in GitHub Desktop.
Save GitHub30/57281870266f1147b05f0d114cd7f804 to your computer and use it in GitHub Desktop.
var conditions = [{lt: 10000, tax: 0}, {ge: 10000, lt: 15000, tax: 100}, {ge: 15000, lt: 20000, tax: 200}, {ge: 20000, tax: 300}];
function accommodationTax(charge){
for(var condition of conditions){
if((!condition.ge || charge >= condition.ge) && (!condition.lt || charge < condition.lt)){
return condition.tax;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment