js打印正三角

file

file

<div id="triangle"></div>
    <style>
        #triangle{font-size: 30px;}
    </style>
    <script>
        let str='';
        let ele = document.getElementById('triangle');
        function triangle(num=3){
            for (let i = 0; i <= num; i++) {
                    str = i+1;
                    ele.innerHTML += "*   ".repeat(str)+"<br/>";
            }
        }
        triangle(9)

点击查看 原文地址

版权声明:本文为wjcms原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/wjcms/p/12643259.html