0

Sorry I'm a javascript beginner. I have a problem with my data. I hope someone can give me solution (with the documentation of js or answer in here). I have arrays

var array1 = ["you","they","them","he","she","it"];
var array2 = ["we","us","me","I"];

and I have an array to save that arrays

var data = [][]; //I don't know how to write.

how to save that array1 and array2 in data? and how to print that data? thanks.

Gilang Pratama
  • 417
  • 6
  • 17

2 Answers2

2

Start off by creating an array

var arr = [];

and simply push your other arrays to it

arr.push(["you","they","them","he","she","it"]);
arr.push(["we","us","me","I"]);

You can retrieve individual items like so

var youVar = arr[0][0]; // has value "you"
Jamiec
  • 128,537
  • 12
  • 134
  • 188
1

Try this.

var array1 = ["you","they","them","he","she","it"];
var array2 = ["we","us","me","I"];

var mergedArray = [];
mergedArray.push(array1);
mergedArray.push(array2);
console.log(mergedArray); //To access the merged array
console.log(mergedArray[0]); //To access first array
console.log(mergedArray[0][0]); //To access element inside first array
Hassan Imam
  • 20,493
  • 5
  • 36
  • 47