<script> for (let i = -3; i < 4; i++) { // 用到了y = |x|函数的思想 const empty = Math.abs(i % 4); let row = ''; for (let j = 0; j < empty; j++) { row += ' '; } for (let j = 0; j < 7 - empty * 2; j++) { row += '*'; } console.log(row); } </script>
标签:++,打印,图案,菱形,let,empty,row From: https://www.cnblogs.com/hello-dummy/p/16775181.html