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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Solution #1694

wants to merge 2 commits into from

Conversation

afesh4ak
Copy link

@afesh4ak afesh4ak commented Dec 2, 2023

No description provided.

Copy link

@anastasiiavorobiova anastasiiavorobiova left a comment

Choose a reason for hiding this comment

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

Great work! Added a few comments to fix


const result = toFormat
.map((part) => {
if (part.includes('YY')) {

Choose a reason for hiding this comment

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

 Consider using variables with meaningful names instead of magic strings

// write code here
const parts = date.split(fromFormat[fromFormat.length - 1]);
const resultMap = new Map();

Choose a reason for hiding this comment

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

Suggested change
const LONG_YEAR_FORMAT = 'YYYY';

const result = toFormat
.map((part) => {
if (part.includes('YY')) {
let year = resultMap.get('YYYY');

Choose a reason for hiding this comment

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

Suggested change
let year = resultMap.get('YYYY');
let year = resultMap.get(LONG_YEAR_FORMAT);

})
.join(toFormat[toFormat.length - 1]);

return result.endsWith(toFormat[toFormat.length - 1])

Choose a reason for hiding this comment

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

Consider simplifying this logic

Copy link
Author

Choose a reason for hiding this comment

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

I use this logic to slice last separator, if date ends with separator

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.

3 participants