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

feat: adding date formatter project for new JS curriculum #52088

Merged
merged 3 commits into from Oct 26, 2023

Conversation

jdwilkin4
Copy link
Contributor

@jdwilkin4 jdwilkin4 commented Oct 25, 2023

This PR is responsible for adding the date formatter project for the new JS curriuclum.
I took the changes from Joy's old PR and Kris' suggestion and incorporated them into this PR.
I also made a couple of small updates to the CSS to fix a couple of issues for smaller devices.

Checklist:

@jdwilkin4 jdwilkin4 self-assigned this Oct 25, 2023
@jdwilkin4 jdwilkin4 requested a review from a team as a code owner October 25, 2023 05:57
@jdwilkin4 jdwilkin4 added scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. front 3 2023 labels Oct 25, 2023
@github-actions github-actions bot added platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. scope: i18n language translation/internationalization. Often combined with language type label labels Oct 25, 2023
@codesee-maps
Copy link
Contributor

codesee-maps bot commented Oct 25, 2023

👀 Review this PR in a CodeSee Review Map

View the CodeSee Map of this change

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@Ksound22
Copy link
Member

I left a few suggestions to fix some nitpicks.

I'll look into the tests tomorrow.

Co-authored-by: Kolade Chris <65571316+Ksound22@users.noreply.github.com>
Co-authored-by: Sem Bauke <semboot699@gmail.com>
Copy link
Member

@zairahira zairahira left a comment

Choose a reason for hiding this comment

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

Went through all the steps, they are easy to understand!

Co-authored-by: Zaira <33151350+zairahira@users.noreply.github.com>
@Sembauke Sembauke enabled auto-merge (squash) October 26, 2023 15:55
@Sembauke Sembauke merged commit ffaa6ec into freeCodeCamp:main Oct 26, 2023
16 of 19 checks passed
@Ksound22
Copy link
Member

This could be the most perfect project 😀


The `Date` object has a number of methods that allow you to get the date and time in different formats.

One of those is the `.getDate()` method, which returns a number between 1-31 that represents the day of the month for that date. For example:
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, missed this the last time I looked at this step, but I figure we can treat the numbers returned by these methods similarly and wrap them all in inline code blocks:

Suggested change
One of those is the `.getDate()` method, which returns a number between 1-31 that represents the day of the month for that date. For example:
One of those is the `.getDate()` method, which returns a number between `1` and `31` that represents the day of the month for that date. For example:


# --description--

The `.getMinutes()` method returns a number between 0 and 59 which represents the minutes for the provided date.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The `.getMinutes()` method returns a number between 0 and 59 which represents the minutes for the provided date.
The `.getMinutes()` method returns a number between `0` and `59` which represents the minutes for the provided date.


# --hints--

You will need to use the `month` constant inside the template literal after a dash.
Copy link
Contributor

Choose a reason for hiding this comment

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

I probably missed this in the other PR, but we could update the hint text here to use the "You should..." format. Maybe something like:

Suggested change
You will need to use the `month` constant inside the template literal after a dash.
You should add a dash followed by the `month` constant to the template literal.


# --hints--

You will need to use the `year` constant inside the template literal after a dash.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
You will need to use the `year` constant inside the template literal after a dash.
You should add a dash followed by the `year` constant to the template literal.


# --description--

In JavaScript, the `change` event is used to detect when the value of an HTML element has changed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Another thing I missed in my original review. Very minor, though:

Suggested change
In JavaScript, the `change` event is used to detect when the value of an HTML element has changed.
In JavaScript, the `change` event is used to detect when the value of an HTML element has changed:


# --description--

In JavaScript, the `.split()` method is used to split up a string into an array of substrings. This method has an optional separator parameter, which indicates where each split should happen.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In JavaScript, the `.split()` method is used to split up a string into an array of substrings. This method has an optional separator parameter, which indicates where each split should happen.
In JavaScript, the `.split()` method is used to split up a string into an array of substrings. This method has an optional separator parameter, which indicates where each split should happen:

In JavaScript, the `.split()` method is used to split up a string into an array of substrings. This method has an optional separator parameter, which indicates where each split should happen.

```js
"coca-cola".split("-"); // [ 'coca', 'cola' ]
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at this again, we might want to add another example of splitting on a space character, and consider capitalizing the strings since they're brand names:

Suggested change
"coca-cola".split("-"); // [ 'coca', 'cola' ]
"Coca-Cola".split("-"); // [ 'Coca', 'Cola' ]
"Diet Coke".split(" "); // [ 'Diet', 'Coke' ]


If your `switch` statement is going to have multiple cases, it is best practice to include a `break` statement.

The `break` statement will tell the JavaScript interpreter to stop executing statements. Without adding a `break` statement at the end of each `case` block, the program will execute the code for all matching `cases`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The `break` statement will tell the JavaScript interpreter to stop executing statements. Without adding a `break` statement at the end of each `case` block, the program will execute the code for all matching `cases`.
The `break` statement will tell the JavaScript interpreter to stop executing statements. Without adding a `break` statement at the end of each `case` block, the program will execute the code for all matching `cases`:

You should add a `break` statement within the `case` after your logic.

```js
assert(code.match(/break/g));
Copy link
Contributor

Choose a reason for hiding this comment

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

It's possible to add the break statement before all the other logic for this case clause and pass the test.

We could probably check that break comes after `.join("-"), and zero or more spaces:

Suggested change
assert(code.match(/break/g));
assert(code.match(/\.join\((['"])-\1\)\;?\n+\s*break/g));

You should include a `break` statement within the `case` after your logic.

```js
assert(code.match(/break/g));
Copy link
Contributor

Choose a reason for hiding this comment

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

This test currently catches the break statement that was added in the last step.

We could make it a bit more specific, since we know that this new break statement should come after the new logic:

Suggested change
assert(code.match(/break/g));
assert(code.match(/currentDateParagraph.textContent\s*=\s*``\;?\n+\s*break/g));


# --hints--

You should assign `${month}-${day}-${year} ${hours} Hours ${minutes} Minutes` inside the `textContent` property of the `currentDateParagraph` constant.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
You should assign `${month}-${day}-${year} ${hours} Hours ${minutes} Minutes` inside the `textContent` property of the `currentDateParagraph` constant.
You should assign `${month}-${day}-${year} ${hours} Hours ${minutes} Minutes` to the `textContent` property of `currentDateParagraph`.


# --hints--

You should use the `default` case to set the `textContent` property of `currentDateParagraph` equal to the constant `formattedDate`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
You should use the `default` case to set the `textContent` property of `currentDateParagraph` equal to the constant `formattedDate`.
You should use the `default` case to set the `textContent` property of `currentDateParagraph` to the value of `formattedDate`.

@jdwilkin4
Copy link
Contributor Author

Hey @scissorsneedfoodtoo !

Since this PR is already closed and merged in we can just open up a new one to apply these changes 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
front 3 2023 platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. scope: i18n language translation/internationalization. Often combined with language type label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants