js打印正三角
<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)
点击查看 原文地址
来源:https://www.cnblogs.com/wjcms/p/12643259.html