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

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

Solution #1908

wants to merge 1 commit into from

Conversation

lmmaarriiaa
Copy link

No description provided.

Copy link

@iAlfreX iAlfreX left a comment

Choose a reason for hiding this comment

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

Good job!

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

Choose a reason for hiding this comment

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

It's better to do it through fromFormat.length - 1

Copy link
Author

Choose a reason for hiding this comment

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

Okay!

Choose a reason for hiding this comment

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

In this very case, this is not critical, as what is exactly the aim of using fromFormat.length - 1?
Personally, I would use access by explicit index

Copy link

@alexander-ignatow alexander-ignatow left a comment

Choose a reason for hiding this comment

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

Good job!
Please, check out some minor comments

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

Choose a reason for hiding this comment

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

In this very case, this is not critical, as what is exactly the aim of using fromFormat.length - 1?
Personally, I would use access by explicit index

let newYearFormat = '';

for (let i = 0; i < fromFormat.length; i++) {
if (fromFormat[i].includes('D')) {

Choose a reason for hiding this comment

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

Again, in this case, you can simply use ==DD, because you don't have other formats with D

Copy link
Author

Choose a reason for hiding this comment

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

Got it, thanks!

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