
String:yearRegex, recording the date stringintervalsRegexparseDate helper and the date string from step 2.Aconsole.log(times); statement, you'll see an array containing objects like:Date.parse.String.prototype.split, which might not be unique depending on whether two days included the same time intervals.times object. To optimize this code, it’d likely be better to use a single reduce over an empty object containing totalHours and times as fields.Posted Jan 16, 2024
My tutorial on working with time intervals in JavaScript made the HackerNoon front page!