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]];
JavaScript

Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon
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;
JesterToo

Juan, are you having a conversation with yourself :)

I don't see how the comment you posted fits with your question.
ASKER CERTIFIED SOLUTION
Julian Hansen

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
juan field

ASKER
thank you so much
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Julian Hansen

You are most welcome.