We help IT Professionals succeed at work.

how can i break an array into a couple

juan field
juan field asked
on
118 Views
Last Modified: 2017-04-11
from this
var arr= [apples, banana, oranges, kiwi];

to this
var newArr = [[apples, banana], [oranges, kiwi]];
Comment
Watch Question

Author

Commented:
// this is good , just wanted to hear another opinion. Thank you.


var results = [];
  while (array.length) {
    results.push(array.splice(0, size));
  }
  return results;
Juan, are you having a conversation with yourself :)

I don't see how the comment you posted fits with your question.
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
thank you so much
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019

Commented:
You are most welcome.