Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariagosp committed Oct 28, 2024
1 parent b1a3d0d commit 3484496
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/calculateRentalCost.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,23 @@
* @return {number}
*/
function calculateRentalCost(days) {
// write code here
const RENT_COST = 40;
const LONG_TERM = 7;
const SHORT_TERM = 3;
const LONG_TERM_DISCOUNT = 50;
const SHORT_TERM_DISCOUNT = 20;

const BASE_PRICE = days * RENT_COST;

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

if (days >= SHORT_TERM) {
return BASE_PRICE - SHORT_TERM_DISCOUNT;
}

return BASE_PRICE;
}

module.exports = calculateRentalCost;

0 comments on commit 3484496

Please sign in to comment.