Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

图片描述

        var cba = "";
        for ( var i = 1 ; i < 9 ; i++ ) {
            //第一行 1*1=1
            //第二行 1*2=1 2*2=2
            //第二行 1*3=1 2*3=2 3*3=9

            for (var j = 1; j <= i ; j++  ) {
                cba += j + "*" + i  + "=" + j * i ;
            }
            console.log( cba );
        }

console.log
图片描述

        var cbb;
        for ( var i = 1 ; i < 9 ; i++ ) {
            //第一行 1*1=1
            //第二行 1*2=1 2*2=2
            //第二行 1*3=1 2*3=2 3*3=9

            for (var j = 1; j <= i ; j++  ) {
                cbb = j + "*" + i  + "=" + j * i ;
            }
            console.log( cbb );
        }

效果图
图片描述


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
149 views
Welcome To Ask or Share your Answers For Others

1 Answer

a += b+c 等价与 a=a+(b+c)

var cba = "";
for ( var i = 1 ; i < 9 ; i++ ) {
    //第一行 1*1=1
    //第二行 1*2=1 2*2=2
    //第二行 1*3=1 2*3=2 3*3=9
   cba = "";
    for (var j = 1; j <= i ; j++  ) {
        cba += j + "*" + i  + "=" + j * i ;
    }
    console.log( cba );
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...