javascript - in the google-sheet script editor - Can't use subsrting function for a string in array -
in code function calls array , string, looks same begging in strings within array.
it goes this:
function tavnit(train, str) { f=0; i=0; while ((f==0) && (i<train.length)) { var trs=train[i]; if (str.substring(0,2)==trs.substring(0,2)) { f=1 } i++ } return f; }
there no errors when saving, when running there -
typeerror: cannot find function substring in object xxvxj. (line 7).
why doesn't reconize string? , how should make recognize it?
i found problem - when google sheet function using column argument - isn't simple array - matrix implemented array of arrays:
[[tvg],[ttxv],[..],..]
so if want call string, first need call array, , second first (and only) object in array -
this way resolved it:
function tavnit(train, str) { f=0; i=0; while ((f==0) && (i<train.length)) { line=train[i]; trs=line[0]; if (sametavnit(str, trs)==1) { return 1; } i++ } return f; }
Comments
Post a Comment