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

sollution #2226

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

sollution #2226

wants to merge 1 commit into from

Conversation

MarushchakM
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! 🎉 Your code meets the task requirements and constraints, effectively handling date format conversions. While there are some areas for improvement, such as making the year conversion logic more flexible and dynamically determining the separator symbol, these are minor issues that don't 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! ✨

Comment on lines +11 to +12
const getSymbol = fromFormat[3];
const setSymbol = toFormat[3];

Choose a reason for hiding this comment

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

Using fromFormat[3] and toFormat[3] to determine the symbol for splitting and joining the date parts assumes that the symbol is always at index 3. This might not be reliable if the format arrays do not contain a symbol at that index. Consider dynamically finding the symbol in the format strings.

if (toFormat[findIndex] !== fromFormat[i]) {
if (toFormat[i] === 'YY') {
findIndex = toFormat.indexOf('YY');
dateIn = dateArr[i].split('').splice(2).join('');

Choose a reason for hiding this comment

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

The logic here assumes that the year is always represented by two digits and needs to be converted to four digits. Ensure that this logic aligns with the expected input and output formats.

Comment on lines +27 to +34
if (dateArr[i] < 30) {
dateIn = dateArr[i].split('');
dateIn.unshift('20');
dateIn = dateIn.join('');
} else if (+dateArr[i] >= 30) {
dateIn = dateArr[i].split('');
dateIn.unshift('19');
dateIn = dateIn.join('');

Choose a reason for hiding this comment

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

The logic for determining whether to prepend '19' or '20' to the year is based on a hardcoded threshold of 30. This may not be accurate for all use cases. Consider making this logic more flexible or configurable.

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