I have an array of numbers and want to determine the starting number and ending number of any numbers that are consecutive. The numbers will always be in ascending order.
I would like to create a function that outputs an array which will look like these examples:
[1,2,3,5,6,7] = [[1,3],[5,7]]
[1,2,4,6,7,8,9,10] = [[1,2],[4],[6,10]]
I have made a few meager attempts but I'm just having difficulty with it for whatever reason. I have attempted to adapt this post with no success.