I have nested multiple array items with cached data that I want to call. I'm looking for a way to reduce the total number of variables in my code.
//function to check for change
function dataChange(oldData, newData){
if(oldData > newData){
alert('change');
}
}
//current code
var num1 = item[key]['b02'][0];
var num2 = item[key]['b02'][1];
var numOld1 = itemOld[key]['b02'][0];
var numOld2 = itemOld[key]['b02'][1];
dataChange(num1,numOld1);
//proposed code
var num1 = ['b02'][0];
var num2 = ['b02'][1];
dataChange(item[key].num1, itemOld[key].num1);