I've kind of stuck on this problem, the goal is to find matching values from column A in column B and increment same values by 1 only in column B, this goes for single aswell as many character strings. Any help would be much appreciated, thanks! This is what I tried:
function compareValuesAndIncrementByOne(){
var ss = SpreadsheetApp.getActive();
var sh = ss.getSheetByName("Data");
var range = sh.getDataRange();
var values = range.getValues();
var headers = values.shift();
var array_1 = [];
var array_2 = [];
for (var i = 0; i < values.length; i++){
array_1.push([values[i][0]]);
array_2.push([values[i][1]]);
array_2[i].join().split(',');
}
try{
for (var i = 0; i < array_1.length; i++){
if (array_1[i].includes(array_2[i])){
var index = array_2[i].findIndex(array_1[i]);
array_2[index] = parseInt(array_1[i])+1;
}
}}catch(e){Logger.log(e)}
Logger.log(array_2);
}
Here is the link to the spreadsheet: https://docs.google.com/spreadsheets/d/1u55xVnGrZfaHedB1UwhQpcuxmtVtkWi-LxDHtU30CwQ/edit?usp=sharing
Desired Result Screenshot
Problem:
When loging the arr_2, values are "1", "2", "1,2,3", "3", but they should actually be "2", "3", "2,3,4", "4"
