Link to home
Start Free TrialLog in
Avatar of juan field
juan field

asked on

how can i break an array into a couple

from this
var arr= [apples, banana, oranges, kiwi];

to this
var newArr = [[apples, banana], [oranges, kiwi]];
Avatar of juan field
juan field

ASKER

// 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.
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you so much
You are most welcome.