How to split an array (which has 10 items) into 4 chunks, which contain a maximum of n
items.
var a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];
//a function splits it to four arrays.
console.log(b, c, d, e);
And it prints:
['a', 'b', 'c']
['d', 'e', 'f']
['j', 'h', 'i']
['j']
The above assumes n = 3
, however, the value should be dynamic.
Thanks