I have an array which always has a length of 50, which looks like so:
var array = [
'item',
'item',
'item',
'item',
'item',
'item',
'item',
'item',
'item',
'item',
'item',
'item',
'item',
'item',
'item',
'item',
'item',
'item',
'item',
'item',
...
];
What I need to do is loop through that array and create a nested array every 5 items, so the end result will be array containing 10 nested arrays which contain 5 items each, looking something like:
var array = [
[
'item',
'item',
'item',
'item',
'item'
],
[
'item',
'item',
'item',
'item',
'item'
],
[
'item',
'item',
'item',
'item',
'item'
],
[
'item',
'item',
'item',
'item',
'item'
],
...
];
I've tried quite a few things which always ends up in a complete mess of spaghetti loops, any help would be greatly appreciated. I'm even open to using jQuery if needs be.