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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Solution #5120

wants to merge 1 commit into from

Conversation

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

Great job on implementing the calculateRentalCost function! 🎉 Your code meets all the task requirements and constraints, and the logic for applying discounts is spot on. While your code is already clear, consider using parentheses in your calculations for added clarity, even though it's not strictly necessary. Keep up the excellent work, and happy coding! 😊

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

Comment on lines +13 to +19
if (days >= LONG_VACATION) {
return ONE_DAY_RENT * days - LONG_VACATION_DISCOUNT;
}

if (days >= SHORT_VACATION) {
return ONE_DAY_RENT * days - SHORT_VACATION_DISCOUNT;
}

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 correct, but ensure that the conditions are mutually exclusive. Since the LONG_VACATION condition is checked first, it correctly prevents the SHORT_VACATION discount from being applied when the LONG_VACATION condition is met.

function calculateRentalCost(days) {
// write code here
if (days >= LONG_VACATION) {
return ONE_DAY_RENT * days - LONG_VACATION_DISCOUNT;

Choose a reason for hiding this comment

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

Consider using parentheses for clarity in the calculation: return (ONE_DAY_RENT * days) - LONG_VACATION_DISCOUNT;. This makes the order of operations explicit, although it is not strictly necessary due to operator precedence.

}

if (days >= SHORT_VACATION) {
return ONE_DAY_RENT * days - SHORT_VACATION_DISCOUNT;

Choose a reason for hiding this comment

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

Similar to the previous comment, consider using parentheses for clarity: return (ONE_DAY_RENT * days) - SHORT_VACATION_DISCOUNT;.

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