Skip to content

Commit

Permalink
transportation-on-vacation solution
Browse files Browse the repository at this point in the history
  • Loading branch information
ibabiuk committed Dec 22, 2024
1 parent b1a3d0d commit 1e514e8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/calculateRentalCost.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@
* @return {number}
*/
function calculateRentalCost(days) {
// write code here
const LONG_TERM = 7;
const LONG_TERM_DISCOUNT = 50;
const SHORT_TERM = 3;
const SHORT_TERM_DISCOUNT = 20;
const BASE_COST = 40;

if (days >= SHORT_TERM && days < LONG_TERM) {
return days * BASE_COST - SHORT_TERM_DISCOUNT;
}

if (days >= LONG_TERM) {
return days * BASE_COST - LONG_TERM_DISCOUNT;
}

return days * BASE_COST;
}

module.exports = calculateRentalCost;

0 comments on commit 1e514e8

Please sign in to comment.