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

done #2211

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

done #2211

wants to merge 1 commit into from

Conversation

EgorMamtsev
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! 🎉 While there are a few minor issues with the premature return statements that could affect the formatting of other date parts, your solution meets the core requirements of the task. Keep up the good work, and consider revising the logic to ensure all parts of the date are formatted before returning. This will make your code even more robust! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

Comment on lines +32 to +39
if (result[index].length === 2) {
return result.join(toFormat[toFormat.length - 1]);
}

if (result[index].length === 4) {
result[index] = result[index].slice(-2);

return result.join(toFormat[toFormat.length - 1]);

Choose a reason for hiding this comment

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

The function returns prematurely if the year is in 'YY' format and is already two digits long. This might not be the intended behavior, as it skips formatting other parts of the date. Consider removing the return statement here and allowing the loop to continue.

Comment on lines +36 to +39
if (result[index].length === 4) {
result[index] = result[index].slice(-2);

return result.join(toFormat[toFormat.length - 1]);

Choose a reason for hiding this comment

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

Similarly, returning here when the year is in 'YYYY' format and is already four digits long may not be correct. Ensure that all parts of the date are formatted before returning.

Comment on lines +46 to +54
if (result[index].length === 2) {
if (+result[index] < 30) {
result[index] = 20 + result[index];

return result.join(toFormat[toFormat.length - 1]);
} else {
result[index] = 19 + result[index];

return result.join(toFormat[toFormat.length - 1]);

Choose a reason for hiding this comment

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

The logic for converting two-digit years to four-digit years is correct, but returning immediately after updating the year might skip formatting other parts of the date. Consider updating the result array without returning immediately.

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