Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
dmdamyan committed Oct 28, 2024
1 parent b1a3d0d commit 44b1e91
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/calculateRentalCost.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@
* @return {number}
*/
function calculateRentalCost(days) {
// write code here
const basePrice = 40;
const shortTerm = 3;
const longTerm = 7;
const smallDiscount = 20;
const bigDiscount = 50;

if (days < shortTerm) {
return days * basePrice;
} else if (days < longTerm) {
return days * basePrice - smallDiscount;
} else {
return days * basePrice - bigDiscount;
}
}

module.exports = calculateRentalCost;

0 comments on commit 44b1e91

Please sign in to comment.