【发布时间】:2022-01-25 00:02:31
【问题描述】:
我对 python 很友好,但我需要在谷歌应用脚本中使用相同的代码。 (代码在正文下方)
提前谢谢你
我需要这样的输出:
plus = [[600, 'ter', 'simple'], [600, 'ter', 'simple']]
这是我的代码:
function myFunction() {
var data =[[600, 'ter', 'simple'], [600, 'ter', 'simple'], [300, 'ter', 'medium'], [200, 'ter', 'Hard']]
var plus = []
for (let i = data[0]; i < data.leng; i++)
{
if ( data[i][0] == data[0][0])
{
plus.push(data)
}
}
}
【问题讨论】:
-
Google Apps 脚本 (js) 中没有您需要使用像
[[], []]这样格式的二维数组的元组。 -
来自javascript tag info:“[JavaScript] 与 Java 编程语言无关,只有表面上的相似之处。...”
-
非常感谢@Turing85,我已经编辑了我的消息
-
您只需将最后一行修改为
plus.push(data[i])。另见stackoverflow.com/questions/63720612/…
标签: javascript for-loop if-statement google-apps-script