How to split an array (which contains 10 elements) into 4 pieces that contain a maximum of n elements.
var a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];
And he prints:
['a', 'b', 'c'] ['d', 'e', 'f'] ['j', 'h', 'i'] ['j']
The above assumes n = 3 , however the value should be dynamic.
thank
javascript arrays
mrdaliri Jul 03 '12 at 20:27 2012-07-03 20:27
source share