This is the array of objects employees
which contains accounting and sales arrays. Is it possible to add new entry to both the accounting and sales array in a single push?
var employees = {
accounting: [ // accounting is an array in employees.
{
"firstName": "John", // First element
"lastName" : "Doe",
"age" : 23
},
{
"firstName": "Mary", // Second Element
"lastName" : "Smith",
"age" : 32
}
], // End "accounting" array.
sales: [ // Sales is another array in employees.
{
"firstName": "Sally", // First Element
"lastName" : "Green",
"age" : 27
},
{
"firstName": "Jim", // Second Element
"lastName" : "Galley",
"age" : 41
}
] // End "sales" Array.
} // End Employees
employees.accounting.push(...)
? What is the problem? Can you show us thefor
loop you're trying to use?arrayfirstname
,arraylastname
, andarrayage
. Please strive to include all relevant information in the questions you ask.