I have a need to take an array...lets say we have this..
var numtosplice = 2; // this is setable...
I want to group from array1 into array2 based on what 'numtosplice' is.
array1 = new Array ('what','hello','mary','john','peter','steve','tiger','funny')
and I want to take that array, and get this...
array2 = new Array(
['what','hello']
['mary','john']
['peter','steve']
['tiger','funny']
)
I know I can cycle thru array1 and set a counter and then do an inner loop.. but i am hoping there is a nifty and cooler way..
any ideas.. perhaps splice and pop????
var numtosplice = 2; // this is setable...
I want to group from array1 into array2 based on what 'numtosplice' is.
array1 = new Array ('what','hello','mary','john','peter','steve','tiger','funny')
and I want to take that array, and get this...
array2 = new Array(
['what','hello']
['mary','john']
['peter','steve']
['tiger','funny']
)
I know I can cycle thru array1 and set a counter and then do an inner loop.. but i am hoping there is a nifty and cooler way..
any ideas.. perhaps splice and pop????
Comment