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
feat: adding date formatter project for new JS curriculum #52088
Conversation
|
👀 Review this PR in a CodeSee Review Map |
...structures-22/learn-the-date-object-by-building-a-date-formatter/65386e889dd615940cb3e042.md
Outdated
Show resolved
Hide resolved
...structures-22/learn-the-date-object-by-building-a-date-formatter/653879d87bc55fa624280c77.md
Outdated
Show resolved
Hide resolved
...structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md
Outdated
Show resolved
Hide resolved
...structures-22/learn-the-date-object-by-building-a-date-formatter/65386e889dd615940cb3e042.md
Outdated
Show resolved
Hide resolved
...structures-22/learn-the-date-object-by-building-a-date-formatter/65387b440b5cb1aa35585820.md
Outdated
Show resolved
Hide resolved
...structures-22/learn-the-date-object-by-building-a-date-formatter/65388d61a57a00b9ad0d0817.md
Outdated
Show resolved
Hide resolved
...structures-22/learn-the-date-object-by-building-a-date-formatter/653883da4a1fabaeb5f1f5e7.md
Outdated
Show resolved
Hide resolved
...structures-22/learn-the-date-object-by-building-a-date-formatter/653884e09dfb4eb01f1622ed.md
Outdated
Show resolved
Hide resolved
...structures-22/learn-the-date-object-by-building-a-date-formatter/653883da4a1fabaeb5f1f5e7.md
Outdated
Show resolved
Hide resolved
...structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md
Outdated
Show resolved
Hide resolved
...structures-22/learn-the-date-object-by-building-a-date-formatter/65388659a72663b27cde0699.md
Outdated
Show resolved
Hide resolved
|
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>
There was a problem hiding this 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!
...structures-22/learn-the-date-object-by-building-a-date-formatter/653879d87bc55fa624280c77.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Zaira <33151350+zairahira@users.noreply.github.com>
|
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: |
There was a problem hiding this comment.
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:
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. |
There was a problem hiding this comment.
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:
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. |
There was a problem hiding this comment.
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:
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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' ] |
There was a problem hiding this comment.
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:
| "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`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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)); |
There was a problem hiding this comment.
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:
| 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)); |
There was a problem hiding this comment.
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:
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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`. |
|
Hey @scissorsneedfoodtoo ! Since this PR is already closed and merged in we can just open up a new one to apply these changes 👍 |

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:
mainbranch of freeCodeCamp.