-
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 #2192
base: master
Are you sure you want to change the base?
solution #2192
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 formatDate
function! 🎉 It meets the task requirements and constraints effectively. While there are some minor improvements suggested, such as making the century logic configurable and avoiding destructive array operations, these do not impact the core functionality. Keep up the good work and consider these suggestions for future enhancements! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
// write code here | ||
const dateParts = {}; | ||
const newDateParts = []; | ||
const split = fromFormat.pop(); |
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.
Using pop()
on fromFormat
modifies the array destructively, which may lead to unexpected behavior if fromFormat
is reused elsewhere. Consider using slice(-1)[0]
to get the last element without modifying the array.
const dateParts = {}; | ||
const newDateParts = []; | ||
const split = fromFormat.pop(); | ||
const newSplit = toFormat.pop(); |
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.
Using pop()
on toFormat
modifies the array destructively, which may lead to unexpected behavior if toFormat
is reused elsewhere. Consider using slice(-1)[0]
to get the last element without modifying the array.
if (year < 30) { | ||
newDateParts.push('20' + (year < 10 ? '0' + year : year)); | ||
} else { | ||
newDateParts.push('19' + year); |
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 determining the century based on a two-digit year assumes that years less than 30 belong to the 2000s and others to the 1900s. This assumption may not be suitable for all use cases. Consider making this logic configurable or documenting this behavior clearly.
No description provided.