I am currently working with an array called 'vnData' that contains 5 to 6 rows. I am attempting to extract values from the 3rd column based on a certain criteria and insert them into a new array. Below is the code I am using:
for (odr = 0; odr < vnData.length; odr++){
Logger.log(vnData);
tempOdr = vnData[odr][3];
Logger.log(odr);
Logger.log(tempOdr);
Logger.log(vnData[odr][3]);
for(k = 0; k < vnData.length; k++){
if(vnData[k][3] = tempOdr){
odrVal = odrVal + vnData[k][11];
}
}
if(odrVal > 0){
affOdrSet.push(tempOdr);
}
Logger.log(affOdrSet);
}
In my testing, the Logger.log(odr);
statement correctly displays the value of odr, but when it comes to Logger.log(vnData[odr][3]);
, I always end up with a result where the value of odr is 0.
For each iteration, I seem to be getting the value from the first row. Can anyone help me identify what might be going wrong here?
Additionally, another strange observation I've made is that if I replace Logger.log(vnData[odr][3])
with Logger.log(vnData[3][3])
, it gives me the correct value from row 4 in the first iteration. However, in all subsequent iterations, even Logger.log(vnData[3][3])
retrieves the value from the first row, which is quite puzzling.