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 #2207

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

Solution #2207

wants to merge 1 commit into from

Conversation

DianaKhala
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 solution meets the task requirements and constraints effectively. While there are a couple of areas for improvement, such as ensuring the input formats are valid and handling delimiters more flexibly, these are minor and do not impact the core functionality. Keep up the great 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! ✨

@@ -8,7 +8,29 @@
* @returns {string}
*/
function formatDate(date, fromFormat, toFormat) {
// write code here
const dateParts = date.split(fromFormat[3]);

Choose a reason for hiding this comment

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

The assumption that the delimiter is always at the fourth position in the fromFormat array might not be safe. Ensure that the format arrays are always structured as expected, or consider a more flexible approach to determine the delimiter.

dateObj[part] = dateParts[index];
});

if (fromFormat.includes('YYYY') && toFormat.includes('YY')) {

Choose a reason for hiding this comment

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

Ensure that the input formats are valid and consistent with the expected structure. The current logic assumes that 'YYYY' and 'YY' are mutually exclusive in the formats, which should be validated before processing.

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