If you push only one time into ticketsToAdd
array,
use,
for(var i=0; i<5; i++) { ticketsToAdd[0]['Attendees'].push({ "EmailID": "", "Phone": "", "FirstName": "", "LastName": "", "Company": "" }) }
But, If you push multiple times, you have to use the index i
Since you are adding more objects into ticketsToAdd
array, while inserting data into that array, use the number i
from the iteration.
use ticketsToAdd.length
to get the length first.
var ticketsToAdd = []; ticketsToAdd.push({ "TicketId": "", "Attendees": [] }) for(var i=0; i<ticketsToAdd.length; i++) { for(var y = 0; y<5; y++) { ticketsToAdd[i]['Attendees'].push({ "EmailID": "", "Phone": "", "FirstName": "", "LastName": "", "Company": "" }) } }
This gets all the objects from the array and pushes 5 times in each of it.
ticketsToAdd['Attendees'].push(
toticketsToAdd[i]['Attendees'].push(