Skip to main content
Known Participant
March 20, 2013
Answered

How can I push arrays into another array?

  • March 20, 2013
  • 2 replies
  • 463 views

This part works. e is the return(e) from aFunction. The + adds two names together with a new line break \n.

for (var i:uint = 0; i < 50 ; i++)

{

          aFunction();

          newArray = [e, oldArray1[0][0]+oldArray1[0][1]];

oldArray1.shift();

}

So the newArray has [e, "name \n other name"]. Like I said this part works fine.

I want to double the part going in, for example:

for (var i:uint = 0; i < 50 ; i++)

{

  aFunction();

  newArray = [[e, oldArray1[0][0]+oldArray1[0][1]], [e, oldArray1[0][0]+oldArray1[0][1]]];

oldArray1.shift();

}

So it would be [ [e, "name \n other name"], [e, "name \n other name"] ]

But I keep getting errors and general not-working-ness from modifying the first part in any way.

This topic has been closed for replies.
Correct answer Andrei1-bKoviI

Try while loop - there is not enough code to tell what role other code part play. Also you should post the errors you get.

while(oldArray1.length > 0) {

          aFunction();

          newArray.push([[e, oldArray1[0][0] + oldArray1[0][1]], [e, oldArray1[0][0] + oldArray1[0][1]]]);

          oldArray1.shift();

}

2 replies

Andrei1-bKoviICorrect answer
Inspiring
March 20, 2013

Try while loop - there is not enough code to tell what role other code part play. Also you should post the errors you get.

while(oldArray1.length > 0) {

          aFunction();

          newArray.push([[e, oldArray1[0][0] + oldArray1[0][1]], [e, oldArray1[0][0] + oldArray1[0][1]]]);

          oldArray1.shift();

}

Inspiring
March 20, 2013