jscript 嵌套循环案例

     *
    ***
   *****
  *******
 *********
***********

<script>

for(var row =1 ; row <=6; row++){
    for(var col=1; col <= (6 - row); col++){
        document.write("&nbsp;");
    }
    var startnum =row *2 -1;
    for(var col=1; col <= startnum; col++){
        document.write("*");
    }
document.write("</br>")


    }
</script>

 

posted @ 2019-04-07 21:43  lyh3420  阅读(172)  评论(0编辑  收藏  举报