kstoyanov

03. Match Dates js fundamentals

Jul 23rd, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(args) {
  2.   const inputString = args.join(' ');
  3.  
  4.   const dates = inputString.match(/\b(?<day>\d{2})([-./])(?<month>[A-Z][a-z]{2})\2(?<year>\d{4})\b/g);
  5.  
  6.   dates.forEach((strDate) => {
  7.     const [day, month, year] = strDate.split(/[-./]/);
  8.  
  9.     console.log(`Day: ${day}, Month: ${month}, Year: ${year}`);
  10.   });
  11. }
Add Comment
Please, Sign In to add comment