Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function returns the total amount for different number of days #4986

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/calculateRentalCost.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
* @return {number}
*/
function calculateRentalCost(days) {
// write code here
let PRICE = days * 40;

if (days >= 7) {
PRICE -= 50;
} else if (days >= 3) {
PRICE -= 20;
Comment on lines +9 to +12

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current logic applies only one discount based on the rental period. According to the task requirements, if the rental period is 7 days or more, a $50 discount should be applied. If the rental period is 3 days or more but less than 7 days, a $20 discount should be applied. Ensure that the correct discount is applied based on these conditions.

}

return PRICE;
}

module.exports = calculateRentalCost;
Loading