Skip to content

Commit

Permalink
introduce quantityDiscount
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiosilveira committed Aug 20, 2022
1 parent b36df25 commit 576ee4b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions function.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
function price(order) {
// price is base price - quantity discount + shipping
const basePrice = order.quantity * order.itemPrice;
const quantityDiscount = Math.max(0, order.quantity - 500) * order.itemPrice * 0.05;
return (
basePrice -
Math.max(0, order.quantity - 500) * order.itemPrice * 0.05 +
Expand Down

0 comments on commit 576ee4b

Please sign in to comment.