[Solved] Find all ranges of consecutive numbers in array [closed]
You can use Array.reduce() to do it: Sort the array (safety) Iterate over the array with reduce to create an object containing the ranges and the start of the active range (rangeStart). On the first iteration, push the first element in the ranges and save this element as the rangeStart On the successive iterations, if … Read more