Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
KateShepel committed Jan 21, 2025
1 parent 9bca09f commit e076afa
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/calculateRentalCost.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@
* @return {number}
*/
function calculateRentalCost(days) {
const priceOfRent = 40;
let totalCost = days * priceOfRent;
const smallDiscount = 20;
const bigDiscount = 50;
const PRICE_OF_RENT = 40;
let totalCost = days * PRICE_OF_RENT;
const SHORT_TERM = 3;
const SMALL_DISCOUNT = 20;
const LONG_TERM = 7;
const BIG_DISCOUNT = 50;

if (days < 3) {
if (days < SHORT_TERM) {
return totalCost;
}

if (days >= 3 && days <= 6) {
totalCost = totalCost - smallDiscount;
if (days < LONG_TERM) {
totalCost = totalCost - SMALL_DISCOUNT;

return totalCost;
}

totalCost = totalCost - bigDiscount;
totalCost = totalCost - BIG_DISCOUNT;

return totalCost;
}
Expand Down

0 comments on commit e076afa

Please sign in to comment.