From 44b1e91fe335266c8f3d6e98feb8193a3329f316 Mon Sep 17 00:00:00 2001 From: Dmitrii Damyan Date: Mon, 28 Oct 2024 16:16:42 +0200 Subject: [PATCH] Solution --- src/calculateRentalCost.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/calculateRentalCost.js b/src/calculateRentalCost.js index 1e3a27d11..7d1807c34 100644 --- a/src/calculateRentalCost.js +++ b/src/calculateRentalCost.js @@ -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;