Among the objects in my possession are:
robot {
id
skill
currentWorkPlace
}
warehouse {
aiStaff
currentStatus
boxes
}
I am tasked with creating a function that will add the id of a new worker to the aiStaff array and assign a reference to the warehouse object to the job in the currentWorkPlace. However, I need to ensure that this function does not alter the original array in the warehouse. ('registerRobot' function must not modify the 'aiStaff' array within the 'warehouse' object) nor can I introduce a new variable.
This is my code snippet:
function registerRobot(robot, warehouse) {
robot.currentWorkPlace = warehouse;
robot.currentWorkPlace.aiStaff = [robot.id];
}
I am struggling with preventing the overwrite of the 'aiStaff' array. Any assistance would be greatly appreciated!