2017-11-20 6 views
-1

に動作していない配列にプッシュ:活字体は、これは私がクラスの下で配列を宣言する方法である

pastq:number[]; 
randomqnumber:number; 

1内部の機能else文:

this.randomqnumber=Math.floor(Math.random() * homework.length)+1; 
    console.log(this.randomqnumber);//got the number 
    this.pastq.push(this.randomqnumber); // not working 
    console.log(this.pastq[0]); //not working 
+1

この場合、「うまくいかない」とはどういう意味ですか、起こっていないことは何ですか?何かエラーが報告されていますか? – Scriptable

答えて

4

を私はあなたがあなたの配列を初期化することを忘れだと思います。

pastq:number[] = []; 
関連する問題