How do I write following "tier pricing with percentage discount" function in JavaScript? I want to specify a US ($) price / quantity lot (i.e. carton) and then as the quantity increases a fixed-price discount or percentage discount is applied and subtracted from the total price as the quantity increases. I also want to display the total price and percentage saved underneath in javascript. Plus the applicable shipping fee inclusive in the total price, depending upon which shipping option a customer chooses. Ex. $42.00 / carton 1 $42.00 2 $39.90 3 - 5 $37.80 6 - 10 $35.70 Total cost: $42.00 Code (markup):