For background, I am trying to assign a list of names to a set of tables that can be sat at. tableQuantity tells us how many tables there are, and tableSize tells us how many seats. I am trying to assign the names from the array guestNames into seating tables, which I would like to be represented by the array of arrays seatAssignments. So, for example, if I asked for seatAssignment[0][3], I should get the person sitting at the first table (index 0) in the 4th seat (index 3).
However I have tried it, all tables end up being copies of whatever the last table is. So, seatAssignment[0] should display an array of the first table, but instead it, along with every other index, displays the last table.
Why is the data being overwritten? Relevant code is below. I have included the alerts to see where things go wrong. alert(currentTable) always shows the correct table that was most recently assigned, but by the time alert(seatAssignments) comes around, I am given x duplicates of the last table.
for (i = 0; i < tableQuantity; i++) {
for (j = 0; j < tableSize; j++) {
currentTable[j] = guestNames[i + (j * tableQuantity)];
seatAssignments[i] = currentTable;
}
alert(currentTable);
}
alert(seatAssignments);