-
Notifications
You must be signed in to change notification settings - Fork 2.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 #1694
base: master
Are you sure you want to change the base?
Solution #1694
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 work! Added a few comments to fix
src/formatDate.js
Outdated
|
||
const result = toFormat | ||
.map((part) => { | ||
if (part.includes('YY')) { |
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 variables with meaningful names instead of magic strings
// write code here | ||
const parts = date.split(fromFormat[fromFormat.length - 1]); | ||
const resultMap = new Map(); | ||
|
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 LONG_YEAR_FORMAT = 'YYYY'; |
src/formatDate.js
Outdated
const result = toFormat | ||
.map((part) => { | ||
if (part.includes('YY')) { | ||
let year = resultMap.get('YYYY'); |
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 year = resultMap.get('YYYY'); | |
let year = resultMap.get(LONG_YEAR_FORMAT); |
}) | ||
.join(toFormat[toFormat.length - 1]); | ||
|
||
return result.endsWith(toFormat[toFormat.length - 1]) |
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 simplifying this logic
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.
I use this logic to slice last separator, if date ends with separator
No description provided.