Skip to content

Instantly share code, notes, and snippets.

View mapodev's full-sized avatar
🏠
Working from home

Marcin Poholski mapodev

🏠
Working from home
View GitHub Profile
@mapodev
mapodev / getCoherentNumbers.js
Last active October 7, 2015 10:26
getCoherentNumbers() - returns blocks of coherent numbers in an array
/**
* getCoherentNumbers([1,2,3,5,6,8,9,10])
*
* returns [[1,2,3], [5,6], [8,9,10]]
*
* Works only for increasing numbers, like 1 2 3 4, not 5,1,3,2,4
*/
var getCoherentNumbers = function getCoherentNumbers(arr) {
var result = [];
var tmpArray = [];