-
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
Solution #5120
base: master
Are you sure you want to change the base?
Solution #5120
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.
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! ✨
if (days >= LONG_VACATION) { | ||
return ONE_DAY_RENT * days - LONG_VACATION_DISCOUNT; | ||
} | ||
|
||
if (days >= SHORT_VACATION) { | ||
return ONE_DAY_RENT * days - SHORT_VACATION_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 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; |
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.
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; |
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.
Similar to the previous comment, consider using parentheses for clarity: return (ONE_DAY_RENT * days) - SHORT_VACATION_DISCOUNT;
.
No description provided.