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

calculate rental amount #4853

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

yzhyhaliuk
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Thank you for your hard work on this task! 😊 While your solution is on the right track, there's a critical issue with the discount logic that needs to be addressed. Currently, both discounts can be applied simultaneously, which is not the intended behavior. You should adjust the logic to ensure only the highest applicable discount is applied. Additionally, consider replacing hardcoded literals with constants for better readability and maintainability, and use const instead of let where possible. Once these changes are made, your code will be much stronger! Keep up the great work! 💪

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

Comment on lines 18 to 19
if (days >= 3) {
return totalSum - 20;

Choose a reason for hiding this comment

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

Logical issue: The current logic applies a $20 discount for rentals of 3 or more days, even if a $50 discount for 7 or more days has already been applied. Consider using an else if statement here to ensure only one discount is applied.

Copy link

@maxim2310 maxim2310 left a comment

Choose a reason for hiding this comment

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

Good job! Let's improve your code a bit)

Comment on lines 10 to 12
for (let day = 1; day <= days; day++) {
totalSum = totalSum + pricePerDay;
}

Choose a reason for hiding this comment

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

i think you can use multiplying for this)

}

if (days >= 7) {
return totalSum - 50;

Choose a reason for hiding this comment

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

looks like magic number, create variable for all discount

Copy link

@VitaliyBondarenko1982 VitaliyBondarenko1982 left a comment

Choose a reason for hiding this comment

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

Looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants