How to group subsequent objects of an array in Javascript

welcome to shbcf.ru