Skip to content

Commit

Permalink
replace discount expression by its variable
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiosilveira committed Aug 20, 2022
1 parent 576ee4b commit a196cf5
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions function.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,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 +
Math.min(basePrice * 0.1, 100)
);
return basePrice - quantityDiscount + Math.min(basePrice * 0.1, 100);
}

module.exports = { price };

0 comments on commit a196cf5

Please sign in to comment.