group-consecutive-numbers
groups all consecutive numbers in
array
Installation
npm install group-consecutive-numbers --save
Usage
const numbers = 1 2 4 6 8 11 7const grouped = console
grouped
variable would be:
If you want to receive only groups that have 3 or more items (array.length
) you can provide second argument:
const grouped =
This time grouped
variable would be: