-3

次のような関数内に for ステートメントがあります。

for(i=0;i<=nc;i++){
var nd = //how many times this for statement has run+1
//if the for statement runs for the first time nd would be 1, second time nd would be 2, the for statement will run a total of "nc" times
this.id=nd }

どうすればこれを達成できますか?

4

3 に答える 3

1

ということですか?

for(i=0;i<=nc;i++){
   var nd = i+1;
   this.id=nd;
}
于 2012-10-13T22:05:31.313 に答える
1

あなたがそれで何を達成しようとしているのかわからない

for(i=0;i<=nc;i++)
{
   this.id = i+1; 
}
于 2012-10-13T22:09:38.247 に答える
0

関数の外で nd を宣言する

var nd = 0;
function...
    nd++;
    this.id = nd;
于 2012-10-13T22:06:42.887 に答える