Hi FE !
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
  • 星号打印

星号打印






function printL(n) {
	if(n < 1) return 
	let starts = n * 2 - 1;
	for(let i = 1; i < starts; i +=2) {
		let spaces = (starts - i) / 2
		console.log(' '.repeat(spaces)+'*'.repeat(i))
	}
	for(let i = starts;i >=1;i -=2) {
		let spaces = (starts - i)/2
		console.log(' '.repeat(spaces)+'*'.repeat(i))
	}
	
}
printL(4)
Edit this page
最近更新: 2025/6/27 02:24
Contributors: qdleader
qdleader
本站总访问量 129823次 | 本站访客数 12人