-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
base: master
Are you sure you want to change the base?
add solution #5126
Conversation
There was a problem hiding this 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.
src/calculateRentalCost.js
Outdated
if (days >= 3) { | ||
totalDiscount = 20; | ||
} | ||
|
||
if (days >= 7) { | ||
totalDiscount = 50; |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
andif
statements withoutelse
. 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! ✨
if (days >= LONG_TERM) { | ||
return RENT_COST * days - LONG_TERM_DISCOUNT; |
There was a problem hiding this comment.
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.
No description provided.