I working with arrays today and am now absolutely exhausted (understatement). For some reason my arrays 'fail to update' (for want of a better word) -or at least so it seems in my console window.
The only way I can get my arrays to 'update' is to 'deep copy' them before I perform further operations, like so:
graphArray = JSON.parse(JSON.stringify(graphArray));
The only way I could get the below code to 'work' (i.e. to 'update' its values) was to deep copy the array between every single step, like so:
//supply
plugIt = graphArray['supplyDemand']['supply'][ind];
graphArray['supplyDemand']['supply'][ind] = parseInt(plugIt) + parseInt(total);
graphArray = JSON.parse(JSON.stringify(graphArray));
//cardiology
plugIt = graphArray['supplyDemand']['cardiology'][ind];
graphArray['supplyDemand']['cardiology'][ind] = parseInt(plugIt) + val.cardiology ;
graphArray = JSON.parse(JSON.stringify(graphArray));
//elderly care
plugIt = graphArray['supplyDemand']['elderly care'][ind];
graphArray['supplyDemand']['elderly care'][ind] = parseInt(plugIt) + val['elderly care'];
graphArray = JSON.parse(JSON.stringify(graphArray));
Can someone please tell me what is going on here?