简单地说,我想用for循环来分配x坐标和y坐标。但它不像c#、c++这样的语言那样工作。这是我的代码:
var coordinate=[[]];
var x, y;
for (x=1; x <= 7; x += 1) {
for (y=1; y <= 5; y += 1) {
coordinate[x][y] = "("+x+","+y+")";
}
}
我该怎么做呢?
var coordinate=[];
var x, y;
for (x=1; x <= 7; x += 1) {
coordinate[x] = [];
for (y=1; y <= 5; y += 1) {
coordinate[x][y] = "("+x+","+y+")";
}
}