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

solution #2192

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

solution #2192

wants to merge 1 commit into from

Conversation

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

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();

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();

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.

Comment on lines +27 to +30
if (year < 30) {
newDateParts.push('20' + (year < 10 ? '0' + year : year));
} else {
newDateParts.push('19' + year);

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.

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.

2 participants