Skip to content

Commit

Permalink
introduce the shipping variable
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiosilveira committed Aug 20, 2022
1 parent a196cf5 commit f08c850
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion function.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ 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 - quantityDiscount + Math.min(basePrice * 0.1, 100);
const shipping = Math.min(basePrice * 0.1, 100);
return basePrice - quantityDiscount + shipping;
}

module.exports = { price };

0 comments on commit f08c850

Please sign in to comment.