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

Solution #5207

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

Solution #5207

wants to merge 2 commits into from

Conversation

saywin
Copy link

@saywin saywin commented Feb 5, 2025

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 code is well-structured and meets many of the task requirements, there's a critical issue with the discount logic that needs to be addressed. Currently, the function applies only one discount, either long-term or short-term, without considering the possibility of both conditions being true. This means that the long-term discount will never be applied if the short-term condition is checked afterward. Please restructure the logic to ensure the correct discount is applied based on the number of rental days. Once this is resolved, your solution will be ready for approval. 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 >= SHORT_TERM) {
return totalCost - SHORT_TERM_DISCOUNT;

Choose a reason for hiding this comment

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

The logic here applies the short-term discount if the number of days is greater than or equal to SHORT_TERM. However, this condition will also be true for long-term rentals (days >= LONG_TERM), which means the long-term discount will never be applied if the short-term condition is checked afterward. Consider restructuring the logic to ensure the correct discount is applied.

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 job on implementing the calculateRentalCost function! 🎉 Your code meets the task requirements and constraints effectively, using descriptive names for constants and avoiding hardcoding, which enhances readability and maintainability. You've also made good use of const for immutable variables and simplified the conditional logic, which is commendable.

However, there's a small issue with the discount logic. Currently, the function applies only one discount based on the rental days, either the long-term or short-term discount, without considering scenarios where both conditions could be applicable. This means the long-term discount condition takes precedence, and the short-term discount might not be applied correctly. Consider restructuring the logic to ensure that the correct discount is applied based on the number of rental days.

Despite this, the decision is to APPROVE your Pull Request to help you move forward with your learning. Please review the comments and address this issue in future implementations to avoid similar problems. Keep up the great work, and continue to improve your code by learning from these insights! 🚀

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

Comment on lines +14 to +17
if (days >= LONG_TERM) {
return totalCost - LONG_TERM_DISCOUNT;
} else if (days >= SHORT_TERM) {
return totalCost - SHORT_TERM_DISCOUNT;

Choose a reason for hiding this comment

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

The logic here applies only one discount, either long-term or short-term, without considering the possibility of both conditions being true. This means that the long-term discount will never be applied if the short-term condition is checked afterward. Consider restructuring the logic to ensure the correct discount is applied based on the number of rental days.

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