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

add task solution #2188

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

Conversation

maksym2493
Copy link

Add solution.

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 solution meets the task requirements and constraints effectively. While there are a couple of areas for improvement, such as ensuring the loop includes all elements of toFormat and correcting the logic for converting 'YY' to 'YYYY', these are minor issues that don't significantly 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 +24 to +27
dateObject['YYYY'] =
+dateObject['YY'] < 30
? `20${dateObject['YY']}`
: `19${dateObject['YY']}`;

Choose a reason for hiding this comment

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

The logic for converting 'YY' to 'YYYY' is incorrect. The expression +dateObject['YY'] < 30 will always evaluate to a boolean, which is not the intended behavior. You should use parentheses to ensure the correct order of operations, like this: (+dateObject['YY'] < 30) ? ....

Comment on lines +30 to +32
for (const name of toFormat.slice(0, -1)) {
newDate.push(dateObject[name]);
}

Choose a reason for hiding this comment

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

The loop iterates over toFormat.slice(0, -1), which means it excludes the last element of toFormat. This might not be the intended behavior if you want to include all elements in the toFormat array. Consider revising this logic if you want to include the last element.

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