0

step by step and a lot of research I made my first custom function. The goal is would be to put into array D the result of the function MyLastCity. The function get the value into the array C,find match in arra A, and put the value of the corresponding index cell in the array B into D array. Now the script works only on console ( like jsbin.com) and only with array filled manual by me.

So i would ask help for:

How can I fill arrays directly by google sheet?

I tried with the function splice finded here (How to insert an item into an array at a specific index?) , but it didn't help me.

link https://docs.google.com/spreadsheets/d/1qUX1Fak-XbOXuonY9VTXWQTARQgpJSPPXQQp1m15xss/edit?usp=sharing

function MyLastCity(){
//A array where to find the value
//B array value to return after match
//C array value to search
//D array value output to show in the google sheet cell
  //var a=[];
  //var b=[];
  //var c=[];
  //var d=[];
  var a=["GIULIANO","ROBERTA","ALFREDO","DUCCIO","STEFANO","GIULIANO"];
  var b=["LONDON","ROME","NY","PARIS","MONTREAL","CUBA"];
  var c=["GIULIANO","ROBERTA","A","B","C","D"];
  var d=[];

  for (var i=0;i<6;i++){   
      if (c[0] === a[i]){
      d[0]=b[i];
      }
  else {  
}
}
return d[0];
}  
Community
  • 1
  • 1

0 Answers0