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

add solution #5126

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

Conversation

VadimKudrenko
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.

It looks like there's a critical issue with the discount logic in your calculateRentalCost function. The current implementation overwrites the discount for 3 or more days when the rental period is 7 or more days, instead of applying both discounts cumulatively. This affects the core functionality of the task. Please adjust the logic to ensure both discounts are applied correctly when applicable. Once you address this, your solution will be much stronger! Keep up the good work, and I'm confident you'll nail it! 😊

✨ 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 10 to 15
if (days >= 3) {
totalDiscount = 20;
}

if (days >= 7) {
totalDiscount = 50;

Choose a reason for hiding this comment

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

The logic for applying discounts is incorrect. Currently, if days is 7 or more, the discount of 20 for 3 or more days is overwritten by the discount of 50 for 7 or more days. To fix this, you should add the discounts cumulatively. Consider using an else if for the 7-day condition or adjusting the logic to ensure both discounts are applied correctly when applicable.

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.

Review Summary

Great effort on implementing the calculateRentalCost function! 🎉 However, there are a few critical issues that need attention:

  • Discount Logic: The current implementation only applies one discount, either for 3 or more days or for 7 or more days. According to the task requirements, both discounts should be applied cumulatively when the rental period is 7 or more days. Please adjust the logic to ensure both discounts are applied correctly.

  • Code Quality: Your code meets the checklist requirements regarding the use of descriptive names, constants instead of literals, and the preferred use of const and if statements without else. Keep up the good work in maintaining clean and readable code!

The decision to approve is made to help you move forward with your learning. Please review the comments and address the critical issues to improve your code. Remember, learning from mistakes is a crucial part of the development process. Keep pushing forward and refining your skills! 🚀

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

Comment on lines +18 to +19
if (days >= LONG_TERM) {
return RENT_COST * days - LONG_TERM_DISCOUNT;

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 the long-term discount for rentals of 7 or more days. According to the task requirements, both the short-term and long-term discounts should be applied cumulatively when the rental period is 7 or more days. Consider adjusting the logic to ensure both discounts are applied.

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.

2 participants