I need a custom object for a staff member so I have this in staff.js:
function Staff(name, shouldBeRemoved, officeName, dateHired) {
this.name = name;
this.shouldBeRemoved = shouldBeRemoved;
this.officeName = officeName;
this.dateHired = dateHired;
}
I also have a custom object for an Office in office.js:
function Office(name, shouldBeRemoved, staffMembers) {
this.name = name;
this.shouldBeRemoved = shouldBeRemoved;
this.staffMembers = staffMembers;
}
I want to use the staffMembers property to be an array of Staff objects inside an Office.
But when I try to push a new staff object into a staffMembers array in my Office object, nothing happens:
staff = new Staff(name, false, officeSelected, d.toDateString());
for (i=0; i<officeArray.length; i++) {
if (officeArray[i].name == officeSelected) {
officeArray[i].staffMembers.push(staff);
}
}