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

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

Solution #2199

wants to merge 1 commit into from

Conversation

diachkinainna
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 handles date format conversions effectively. While there are some assumptions about the format array lengths, they don't impact the core functionality. Keep up the good work, and consider making the loop conditions more flexible in future projects for enhanced adaptability. 😊

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

@@ -8,7 +8,52 @@
* @returns {string}
*/
function formatDate(date, fromFormat, toFormat) {
// write code here
const partsDate = 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 use of fromFormat[3] to split the date assumes that the separator is always at index 3. This might not be correct if the format array has a different length. Consider dynamically determining the separator based on the format array.

let month = '';
let year = '';

for (let i = 0; i <= 3; i++) {

Choose a reason for hiding this comment

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

The loop condition i <= 3 assumes that the fromFormat array always has 4 elements. This might not be the case. Consider using fromFormat.length to make the loop more flexible.


const newPartsDate = [];

for (let i = 0; i <= 3; i++) {

Choose a reason for hiding this comment

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

Similar to the previous loop, the condition i <= 3 assumes a fixed length for the toFormat array. Use toFormat.length to ensure the loop adapts to different format lengths.

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