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

solved #5110

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

solved #5110

wants to merge 1 commit into from

Conversation

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

Your implementation of the calculateRentalCost function is well-structured and meets the task requirements effectively! 🎉 The logic for applying discounts is correct, and the use of constants enhances readability. While the test cases are comprehensive, consider adding comments to clarify the logic and conditions for discounts to improve code readability. Keep up the great work! 🚀

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

Comment on lines +14 to +15
if (days >= LONG_TERM) {
return RENT * days - LONG_TERM_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 the long-term discount is correct. However, consider adding comments to explain the logic for better readability.

Comment on lines +18 to +19
if (days >= SHORT_TERM) {
return RENT * days - SHORT_TERM_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 the short-term discount is correct. Adding comments to explain the conditions and calculations could improve code readability.

return RENT * days - SHORT_TERM_DISCOUNT;
}

return RENT * days;

Choose a reason for hiding this comment

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

The return statement for rentals less than the short-term threshold is correct. Consider adding a comment to clarify that this is the default case with no discounts applied.

@@ -3,21 +3,17 @@
const calculateRentalCost = require('./calculateRentalCost');

test(`Do not add any discount for less than 3 days`, () => {
expect(calculateRentalCost(2))
.toBe(80);
expect(calculateRentalCost(2)).toBe(80);

Choose a reason for hiding this comment

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

The expected value for 2 days of rental should be 80, which is correct given the rental rate of 40 per day with no discount.

});

test('Should add the basic discount from 3 to 6 days of rent', () => {
expect(calculateRentalCost(3))
.toBe(100);
expect(calculateRentalCost(3)).toBe(100);

Choose a reason for hiding this comment

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

The expected value for 3 days of rental should be 100, which is correct as it includes the short-term discount of 20.

});

test('Should add the basic discount from 3 to 6 days of rent', () => {
expect(calculateRentalCost(6))
.toBe(220);
expect(calculateRentalCost(6)).toBe(220);

Choose a reason for hiding this comment

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

The expected value for 6 days of rental should be 220, which is correct as it includes the short-term discount of 20.

});

test('Should add an additional discount for 7 and more days of rent', () => {
expect(calculateRentalCost(7))
.toBe(230);
expect(calculateRentalCost(7)).toBe(230);

Choose a reason for hiding this comment

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

The expected value for 7 days of rental should be 230, which is correct as it includes the long-term discount of 50.

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.

3 participants