Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Reformat a Date

Beyond the Coursehard

Implement `reformatDate(s)` converting a date from `YYYY-MM-DD` to `DD/MM/YYYY` using capture groups.

Sample tests

Input: reformatDate("2024-01-15")
Output: "15/01/2024"
Input: reformatDate("1999-12-31")
Output: "31/12/1999"

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Mismatched group counts or wrong digit lengths.

Learning resources

  • MDN: Regular expressions
Visualize this concept: Regular Expressions →
Approach & explanation (try first)

Capture groups for each date part let the replacement reorder them into DD/MM/YYYY.

Loading...
⌘/Ctrl + Enter

Run your code to see results.