← Back to challenges

Palindromic Dates

JavaScriptHarddatesstringsvalidation

Instructions

The 2nd of February 2020 is a palindromic date in both dd/mm/yyyy and mm/dd/yyyy format (02/02/2020). Given a date in dd/mm/yyyy format, return true if the date is palindromic in both date formats, otherwise return false.

Examples

palindromicDate("02/02/2020") ➞ true

palindromicDate("11/12/2019") ➞ false

palindromicDate("11/02/2011") ➞ false
// Although 11/02/2011 is palindromic in dd/mm/yyyy format,
// it isn't in mm/dd/yyyy format (02/11/2011)

Notes

  • All dates will be valid in both date formats.
  • The date must be palindromic in both dd/mm/yyyy and mm/dd/yyyy formats to pass.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: RegEx: Boundary Assertions VI