シートから一連の値に基づいて辞書を作成する機能があります。次に、キーを使用してそのシートから値の1つを取り出します。それは、コンソールにログを記録するために正常に動作します。しかし、ifステートメントでは、構文エラーとは何も言わない。私はそれを把握することはできません。ここで、クラッシュする関数とコードを示します。この問題はforループでのみ発生し、その外側では発生しません。Google Apps Script辞書の構文エラー
//creates dictionary
function columnLocationWithNotation(notation) {
var spreadsheet = SpreadsheetApp.openByUrl();
var sheet = spreadsheet.getActiveSheet();
var data = sheet.getDataRange();
var cells = data.getValues();
var dictionary = {};
switch (notation) {
case "zeroIndex":
for (var i = 0; i < sheet.getLastRow(); i++) {
dictionary[cells[i][0]] = cells[i][1]
}
return dictionary
break;
case "regularIndex":
for (var i = 0; i < sheet.getLastRow(); i++) {
dictionary[cells[i][0]] = cells[i][2]
}
return dictionary
break;
case "string":
for (var i = 0; i < sheet.getLastRow(); i++) {
dictionary[cells[i][0]] = cells[i][3]
}
return dictionary
break;
}
}
var master0indexDictionary = columnLocationWithNotation("zeroIndex")
for (var i = 1; i =< (sheet.getLastRow() - 1); i++) {
var phone = master0indexDictionary["Tutor Name"]
if (cells[i][phone] === phoneNumber) { //LINE WITH SYNTAX ERROR
//do something
}
if(cells [i] [phone] === phoneNumber){''の行には '' cells''が定義されていないようです。 '' columnLocationWithNotation() ''で定義された '' cells''は、関数の外部では使用できません。 if(cells [i] [phone] === phoneNumber){''で '' cells''が同じスコープで定義されていれば、あなたの個人情報なしでエラーメッセージとスクリプト全体について教えてください。 – Tanaike