I have an array that looks like this:
var arr = [12, 13, 14, 17, 18, 19, 20]
I'm trying to figure out how to iterate through this array and split it into two arrays based on sequences. Essentially, if i+1 != true
, I want to create a new array.
var arr = [12, 13, 14]
var arr2 = [17, 18, 19, 20]
I've been using lodash and experimenting with different for
loops and splice
methods, but I'm starting to feel a bit confused. Any assistance would be greatly appreciated.