Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在GoogleSheet脚本编辑器中-不能对数组中的字符串使用substring函数_Javascript_Arrays_Google Sheets - Fatal编程技术网

Javascript 在GoogleSheet脚本编辑器中-不能对数组中的字符串使用substring函数

Javascript 在GoogleSheet脚本编辑器中-不能对数组中的字符串使用substring函数,javascript,arrays,google-sheets,Javascript,Arrays,Google Sheets,在我的代码中,函数调用数组和字符串, 它在所有的字符串中寻找相同的乞讨 在数组中 事情是这样的: 函数tavnittrain,str{ f=0; i=0; 当f==0&&i时,当googlesheet函数使用列作为参数时,我发现了问题- 它不是一个简单的数组-它是一个实现为数组数组的矩阵: [[tvg],[ttxv],[..],..] 因此,如果要调用字符串,首先需要调用i数组,其次是数组中的第一个也是唯一的对象- 我就是这样解决的: function tavnit(train, str)

在我的代码中,函数调用数组和字符串, 它在所有的字符串中寻找相同的乞讨 在数组中

事情是这样的:

函数tavnittrain,str{ f=0; i=0;
当f==0&&i时,当googlesheet函数使用列作为参数时,我发现了问题- 它不是一个简单的数组-它是一个实现为数组数组的矩阵:

[[tvg],[ttxv],[..],..]
因此,如果要调用字符串,首先需要调用i数组,其次是数组中的第一个也是唯一的对象-

我就是这样解决的:

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;
}

您是否尝试过str.toString.substring0,2?这取决于您作为str推送的内容。