📌  相关文章
📜  hackerrank 楼梯解决方案 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:18.710000             🧑  作者: Mango

代码示例2
function staircase(n) {
 let space = []
 let stair = "#"
 let result
 
 for (let i = 1; i <= n; i++) {
    space.push(' '.repeat(i))
 }
 
 let rotateSpace = space.reverse()

 for(let j = 1; j <= n; j++) {
  
  result = rotateSpace[j - 1] + stair.repeat(j)
  console.log(result.replace(' ', ''))
 }
}