I have a scenario where I need to compare values in two arrays by running a condition. The data is pulled from a spreadsheet, and if the condition is met, I want to copy the respective data.
For instance, I aim to compare two cells within a spreadsheet - copying the higher value from one cell and updating the lower value in the second cell. Being new to coding, I would appreciate any advice or guidance on how to approach this.
function copyRANGEHIGH() {
var NEWHIGH = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("INDEX-RANGE");
var OLDHIGH = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("INDEX-RANGE");
var VALNEWHIGH1 = NEWHIGH.getRange("U4").getValues(); //DIA
var VALOLDHIGH1 = OLDHIGH.getRange("P5").getValues();
var VALNEWHIGH2 = NEWHIGH.getRange("U22").getValues();//SPY
var VALOLDHIGH2 = OLDHIGH.getRange("P23").getValues();
var VALNEWHIGH3 = NEWHIGH.getRange("U39").getValues();//IWM
var VALOLDHIGH3 = OLDHIGH.getRange("P40").getValues();
var arr1=[VALNEWHIGH1,VALNEWHIGH2,VALNEWHIGH3];
var arr2=[VALOLDHIGH1,VALOLDHIGH2,VALOLDHIGH3];
for (var i=0; i < arr1.length; i++) {
for (var j=0; j < arr2.length; j++) {
// Browser.msgBox(arr1[i])
if ( arr1[i] > arr2[j] ) {