Skip to content

Conversation

@gabriel-1607
Copy link
Contributor

@gabriel-1607 gabriel-1607 commented Jan 23, 2026

Description

I modified one line and added another line.
The incrementDay function was intended to return a Date instance, as stated in the inline JS comment; however, it just returns a Unix time number. My small fix is returning the Date instance instead of returning the return value of the setDate method of Date.

The current inline JS comment shows 2019-06-20 as the return value of the function, despite the real output, on testing, would be Unix and, thus, something like 1561006800.

Motivation

This small intended improvement to the JS example is an opportunity to showcase my progress in the understanding and mastery of web technologies such as JavaScript, which will serve my professional career or even my personal satisfaction, because I will be able to display this as my accomplisment of contributing to MDN docs, which are an authoritative and prestigious source of information.

Additional details

Here is the link to the section of the page where the example is found.

Related issues and pull requests

There are no related issues or pull requests to this single line fix, as far as I know.

One line modified and one line added.
The incrementDay function was intended to return a Date instance, as stated in the inline JS comment; however, it just returns a Unix time number.
My small fix is returning the Date instance instead of returning the return value of the setDate method of Date.
@gabriel-1607 gabriel-1607 requested a review from a team as a code owner January 23, 2026 20:25
@gabriel-1607 gabriel-1607 requested review from sideshowbarker and removed request for a team January 23, 2026 20:25
@github-actions github-actions bot added Content:JS JavaScript docs size/xs [PR only] 0-5 LoC changed labels Jan 23, 2026
Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

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

Great catch, thank you!

@gabriel-1607
Copy link
Contributor Author

gabriel-1607 commented Jan 23, 2026

Josh-Cena, the point of this example, what it is intended to show, is that the original instance of Date is modified.

Your fix to the code makes the example out of place. Another example could be made to show the correct way avoid the mutability of class instances.

EDIT: sorry, your fix still changes the original instance. Forget about this comment.

@gabriel-1607
Copy link
Contributor Author

Thank you too, Josh!

@github-actions
Copy link
Contributor

Preview URLs (1 page)

@Josh-Cena Josh-Cena merged commit 8fc371f into mdn:main Jan 23, 2026
8 checks passed
@Josh-Cena
Copy link
Member

Yes, the intention is to show that it "looks like" a new instance is returned but in fact the original is still modified, so your confusion is on point :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:JS JavaScript docs size/xs [PR only] 0-5 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants