-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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 #4837
base: master
Are you sure you want to change the base?
Solution #4837
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.
молодець, дуже гарно і зрозуміло написано)))
src/calculateRentalCost.js
Outdated
const getOff3days = 20; | ||
let totalCost = rentCostForOneDay * days; | ||
|
||
if (days >= 7) { |
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.
краще використати константу замість простого числа, так само і до наступного )
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.
тепер все взагалі ідеально))
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.
Good work 👍
Just a few minor fixes are needed
src/calculateRentalCost.js
Outdated
const rentCostForOneDay = 40; | ||
const LONG_TERM_DISCOUNT = 50; | ||
const SHORT_TERM_DISCOUNT = 20; | ||
const LONG_TERM = 7; | ||
const SHORT_TERM = 3; |
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.
All constants should be in UPPER_CASE and move them outside the function
src/calculateRentalCost.js
Outdated
let totalCost = rentCostForOneDay * days; | ||
|
||
if (days >= LONG_TERM) { | ||
totalCost -= LONG_TERM_DISCOUNT; | ||
} else if (days >= SHORT_TERM) { | ||
totalCost -= SHORT_TERM_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.
let totalCost = rentCostForOneDay * days; | |
if (days >= LONG_TERM) { | |
totalCost -= LONG_TERM_DISCOUNT; | |
} else if (days >= SHORT_TERM) { | |
totalCost -= SHORT_TERM_DISCOUNT; | |
} | |
const totalCost = rentCostForOneDay * days; | |
if (days >= LONG_TERM) { | |
return totalCost - LONG_TERM_DISCOUNT; | |
} | |
if (days >= SHORT_TERM) { | |
return totalCost - SHORT_TERM_DISCOUNT; | |
} |
Prefer if with return over if else to simplify later conditions.
@@ -3,8 +3,24 @@ | |||
* | |||
* @return {number} | |||
*/ | |||
const RENTCOSTFORONEDAY = 40; |
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.
const RENTCOSTFORONEDAY = 40; | |
const RENT_COST_FOR_ONE_DAY = 40; |
No description provided.