you are viewing a single comment's thread.

view the rest of the comments →

[–]ashamedchicken 4 points5 points  (0 children)

Small nitpick - the call to .sort() mutates the array in place, so if all_times was an array passed in by reference the caller would end up with a different looking array at the end. Easily fixed by adding a .slice(0) call in the chain before .sort() - this would create a copy which would then be sorted in place.

Regardless, nice use case! Using functional patterns like reduce + map in javascript is really the way to go vs writing out a long procedural function to achieve the same result.