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

function returns the total amount for different number of days #4986

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

Conversation

vlavrentieva
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 small issue with how discounts are applied in your calculateRentalCost function. Currently, only one discount is applied even if both conditions for discounts are met. To ensure the correct discount is applied, you might want to adjust the logic to consider both discounts when the rental period is 7 days or more. Keep up the great work, and once you fix this, your solution will be spot on! 😊

✨ 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 14 to 24
if (DAYS >= LONG_TERM) {
const LONG_TERM_TOTAL = DAYS * ONE_DAY_PRISE - LONG_TERM_DISCOUNT;

return LONG_TERM_TOTAL;
}

if (DAYS >= MIDDLE_TERM) {
const MIDDLE_TERM_TOTAL = DAYS * ONE_DAY_PRISE - MIDDLE_TERM_DISCOUNT;

return MIDDLE_TERM_TOTAL;
}

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. If the number of days is greater than or equal to 7, both the 7-day and 3-day discounts should be considered. Currently, only the 7-day discount is applied. You should adjust the logic to ensure that the correct discount is applied based on the number of days. Consider using a single return statement at the end of the function to calculate the total cost after determining the applicable discount.

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! 🎉 While the logic for applying discounts is on the right track, there are a few areas that need improvement to fully meet the task requirements:

  1. Discount Logic: Ensure that the correct discount is applied based on the rental period. If the rental period is 7 days or more, a $50 discount should be applied. If it's 3 days or more but less than 7 days, a $20 discount should be applied.

  2. Use of Constants: Avoid using hardcoded literals for discount values and the number of days. Define constants for these values to make your code more maintainable and readable.

  3. Variable Declaration: Use const instead of let for the PRICE variable since its value does not change after initialization. This aligns with best practices and the checklist requirements.

  4. Conditional Logic: Simplify your conditional logic by using if statements with return instead of else if. This will make your code cleaner and easier to follow.

By addressing these points, you'll improve the structure and readability of your code. Remember, these changes are crucial for maintaining code quality and ensuring that your solution meets the task requirements. Keep up the good work, and use this feedback to enhance your coding skills! 🚀

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

Comment on lines +9 to +12
if (days >= 7) {
PRICE -= 50;
} else if (days >= 3) {
PRICE -= 20;

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 one discount based on the rental period. According to the task requirements, if the rental period is 7 days or more, a $50 discount should be applied. If the rental period is 3 days or more but less than 7 days, a $20 discount should be applied. Ensure that the correct discount is applied based on these conditions.

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