So I have some arrays (in reality I have about 30-40):
var p1 = ["John", "bio", "john.png"];
var p2 = ["Kate", "bio", "kate.png"];
var p3 = ["Mary", "bio", "mary.png"];
which have the respective information for each person I want to use in my HTML.
I want to add each of these arrays to another array to have a final result of:
var people = [["John", "bio", "john.png"],
["Kate", "bio", "kate.png"],
["Mary", "bio", "mary.png"]];
Is there a way of adding all these p1
, p2
, p3
arrays to the people
array using a for loop?
I tried this:
for (var i = 1; i <= 30; i++) {
var toPush = "p" + i;
people.push(toPush);
}
But obviously this just creates and pushes strings into the array. How can I get around this?
Thanks!