Skip to content

Commit

Permalink
solution
Browse files Browse the repository at this point in the history
  • Loading branch information
VitaliiShc committed Oct 28, 2024
1 parent b1a3d0d commit d2a47d5
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/calculateRentalCost.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,25 @@
*
* @return {number}
*/

const COST_PER_DAY = 40;
const MIDDLE_PERIOD = 3;
const MIDDLE_PERIOD_DISCOUNT = 20;
const LONG_PERIOD = 7;
const LONG_PERIOD_DISCOUNT = 50;

function calculateRentalCost(days) {
// write code here
const rentalCost = days * COST_PER_DAY;

if (days >= MIDDLE_PERIOD && days < LONG_PERIOD) {
return rentalCost - MIDDLE_PERIOD_DISCOUNT;
}

if (days >= LONG_PERIOD) {
return rentalCost - LONG_PERIOD_DISCOUNT;
}

return rentalCost;
}

module.exports = calculateRentalCost;

0 comments on commit d2a47d5

Please sign in to comment.