Create ranges from an array or list in Javascript

Below a javascript, the function creates logical ranges from an array of integers. I use this script to create filters. The function accepts 4 parameters:

array : an array of integers. E.g. [1,50,20,10,23,78]

range : Integer. Range of the groups. E.g. 10 return groups of 10: 10,20,30 etc. 100 returns groups of 100: 100,200,300 etc. Any integer is possible

divider :

onlyRangesWithValues : Boolean determine if empty groups are returned or not. The default value is true.

Leave a Reply

Your email address will not be published. Required fields are marked *