About
Pricing
Community
Teams
Start Free Trial
Log in
juan field
asked on
4/10/2017
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
5
1
Last Comment
Julian Hansen
8/22/2022 - Mon
juan field
4/10/2017
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
4/10/2017
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
4/11/2017
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
4/11/2017
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
4/11/2017
You are most welcome.
var results = [];
while (array.length) {
results.push(array.splice(
}
return results;