Skip to content

Instantly share code, notes, and snippets.

@jeanlescure
Created October 21, 2019 20:24
Show Gist options
  • Save jeanlescure/16ab8f1103337999b6275078e9d7a37a to your computer and use it in GitHub Desktop.
Save jeanlescure/16ab8f1103337999b6275078e9d7a37a to your computer and use it in GitHub Desktop.
// Given a string containing a list of dates in either format dd/mm/yyyy or mm/dd/yyyy
// where there's one date per line within the string
let a=`28/09/2019
30/09/2019
30/09/2019`;
// Reverse the date's day and month values and return a string with same input format
a = a.split("\n").map((d)=>d.split('/')).map((da)=>([da[1],da[0],da[2]]).join('/')).join("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment