所以我开始编辑这段代码,这样我就可以创建单词了。最终复制了Alan Turing的Bombe。然而,在我上次编辑后,我的"任务"变得无效?现在我很困惑,特别是因为我不是100%熟悉google-apps-script。
以下是我目前的脚本:
function bombeCode2() {
var fastRotor = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
"O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
];
var mediumRotor = fastRotor;
var slowRotor = fastRotor;
var rows = 26;
var columns = 26;
for (var i = 0; i < rows; i++) {
Logger.log('Outer Loop: value of i : ' + i);
// Logger.log("Partition for Outer Loop");
// Logger.log(" ");
var fastRotorValue = fastRotor[i];
for (var j = 0; j < columns; j++) {
Logger.log('-Inner Loop value of j : ' + j);
//var fastRotorValue = fastRotor[i];
var medRotorValue = mediumRotor[j];
// Logger.log("---- " + fastRotorValue + " " + medRotorValue);
for (var k = 0; k < 26; k++) {
// Logger.log('---- XXXX Third Loop value of k : ' + k);
//var fastRotorValue = fastRotor[i];
//var medRotorValue = mediumRotor[j];
var slowRotorValue = slowRotor[k];
if ("---- XXXX " + fastRotorValue + " " + medRotorValue + " " + slowRotorValue = "WEATHER") {
Logger.log("---- XXXX " + fastRotorValue + " " + medRotorValue + " " + slowRotorValue = "WEATHER")
}
// Logger.log("---- XXXX " + fastRotorValue + " " + medRotorValue + " " + slowRotorValue);
};
//var objectNumberValuePair = {"0":"A", "1":"B", "2":"C","3":"D","4":"E","5":"F","6":"G","7":"H","8":"I",
// "9":"J","10":"K","11":"L","12":"M","13":"N","14":"O","15":"P","16":"Q","17":"R",
// "18":"S","19":"T","20":"U","21":"V","22":"W","23":"X","24":"Y","25":"Z"}
// Logger.log(slowRotorValue = objectNumberValuePair);
// Logger.log(medRoterValue = objectNumberValuePair);
// Logger.log(fastRoterValue = objectNumberValuePair);
}
}
}
是的我知道其中一半是无用的。然而,这只是我记得一切都是/做的。 有谁知道如何解决这个问题?#34;任务?&#34;以下是它给出的错误消息&#34;无效的分配左侧。 (第1行,文件&#34; B.测试2&#34;)。&#34;
答案 0 :(得分:0)
您正在if语句中执行变量赋值。
尝试使用有效的js-syntax:
var compareValue = "---- XXXX " + fastRotorValue + " " + medRotorValue + " " + slowRotorValue;
if (compareValue === "WEATHER"){
Logger.log(compareValue + ' === "WEATHER"');
}