JavaScript30 day 18: Adding up times with Reduce

Challenge: Add up a list of times stored in list item data attributes. To do this we need to get minutes and seconds separately, store in an array, convert to seconds and add them together.

I’ve done something similar before and took a more long-winded for loop approach. It turns out that map and reduce can be combined to do the same thing.


The source is available at github and the live version is here. There’s not a great deal to see but check the console for time totals.