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 #5114

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

Solution #5114

wants to merge 2 commits into from

Conversation

srvalle
Copy link

@srvalle srvalle commented Jan 17, 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.

It looks like there's a small issue with the discount logic in your calculateRentalCost function. The discount should only be applied if the rental period is 3 or more days, but currently, it's being applied for any number of days. Please adjust the condition to ensure the discount is only applied when days >= 3. Once that's fixed, your solution will be spot on! 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.

function calculateRentalCost(days) {
// write code here
const COST_CAR_DAY = 40;
const COST_CAR_DISCOUNT = days >= 7 ? 50 : 20;

Choose a reason for hiding this comment

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

The discount logic is incorrect. According to the requirements, a discount should only be applied if the rental period is 3 or more days. The current logic applies a discount for any number of days, which is not correct. Consider revising the condition to apply the discount only when days >= 3.

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 addressing the initial issue with the discount logic in the calculateRentalCost function! The discount is now correctly applied for rental periods of 3 or more days. 🎉

However, there are a few areas for improvement to enhance the readability and maintainability of your code:

  1. Descriptive Naming: Consider renaming the variable COST_CAR_DISCOUNT to something more descriptive, like DISCOUNT_AMOUNT, to clearly indicate its purpose.

  2. Use of Constants: Instead of using literals directly in your expressions, define constants such as LONG_TERM_DAYS, LONG_TERM_DISCOUNT, SHORT_TERM_DAYS, and SHORT_TERM_DISCOUNT. This will make your code more readable and easier to maintain.

  3. Simplification of Conditional Logic: The conditional logic for determining the discount can be simplified by using separate conditions for each discount type. This will make the code clearer and more straightforward.

Remember, these improvements are not just about meeting the task requirements but also about writing clean and maintainable code. Keep up the great work, and continue to learn and grow from each coding experience! 🚀

If there are any critical issues, ensure they are addressed in future projects to avoid similar problems. Keep pushing forward, and don't hesitate to review the comments to refine your code further.

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

function calculateRentalCost(days) {
// write code here
const COST_CAR_DAY = 40;
const COST_CAR_DISCOUNT = days >= 7 ? 50 : 20;

Choose a reason for hiding this comment

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

The discount logic here applies a discount of 50 for 7 or more days and 20 for 3 to 6 days. According to the task requirements, the discount should only be applied if the rental period is 3 or more days, and the discount amount should be consistent. Please adjust the logic to ensure the discount is only applied when days >= 3 and use the correct discount value.

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