2016-03-29 1 views
0

私はmath.random()を使用します。なぜmath.floorを追加するとプログラムが動作しなくなるのですか?Javascript。関数math.floor(math.random()* 10 + 1)の代わりに関数が正しく動作するように、関数math.floorを追加するとcalc()関数は機能しません。

for(x=0; x< 5; x++){ 

    var a = Math.floor(Math.random() * 10 +1) ; 
    var b = math.floor(Math.random() *10 +1) ; 
    var c = math.floor(Math.random() *10 +1) ; 
    var d = math.floor(Math.random() *10 +1) ; 

     document.write((a*b)/(c*d)+"<br>") ; 
+1

これはまあ問題ではありませんか? (数学の代わりに数学) –

答えて

0

MathMはあなたの最初の変数代入のように、大文字にする必要がありますので:

var a = Math.floor(Math.random() * 10 + 1) ; 
3

あなたは小文字math代わりのタイトルケースMathを使用しています。

for(x=0; x< 5; x++){ 
    var a = Math.floor(Math.random() * 10 +1) ; 
    var b = Math.floor(Math.random() *10 +1) ; 
    var c = Math.floor(Math.random() *10 +1) ; 
    var d = Math.floor(Math.random() *10 +1) ; 
} 
document.write((a*b)/(c*d)+"<br>") ; 
関連する問題