我将数据从一个函数传递到另一个有循环的函数。循环仅执行一次,而不是data.length。请帮忙。
function first(){
//start code...
var symbol = filetext.substr(filetext.search("Title:"));
symbol = symbol.split(' ');
symbol = symbol[1]; //someText
if(symbol == 'someText') {
second(symbol);
}
}
function second(symbol){
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('tests');
var range = sheet.getRange(1,1,sheet.getLastRow(),sheet.getLastColumn());
var data = range.getValues();
for (var i = 0; i < data.length; i++){ //data has at least 10 rows
var row = data[i];
var type = row[0];
var status = row[3];
Logger.log(type) //shows only first row not all;
if (type == symbol) {
//do something
}
}
}