js for和while两种99乘法表

<script type="text/javascript">
    for(var i=1; i<=9; i++)
    { 
        for(var j=1; j<=i;j++)//j<=i 
        { 
            document.write(i+"*"+j+"="+(i*j)+"&nbsp;&nbsp;&nbsp;");
        }
        document.write("<br>");
    }
    document.write("<br>");
</script>
<script type="text/javascript">
var i=1,j;
while(i<=9){
    j=1;
    while(j<=i){
        document.write(i+"*"+j+"="+(i*j)+"&nbsp;&nbsp;&nbsp;");
        j++;
    }
    i++;
    document.write("<br>")
}
</script>

 

posted @ 2017-11-21 11:03  雨落知音  阅读(1604)  评论(0编辑  收藏  举报