문제
배운것
-
"str".repeat() 함수 - 특정 문자를 반복해주는 함수
-
Array(n).fill(arg) - 특정 arg 를 n 번 채워서 가지고 있는 배열 반환
풀이
function staircase(n) {
const hash = "#", space = " "
for (let i = n - 1, j = 1 ; -1 < n && j < n + 1 ; j++, i--){
console.log(space.repeat(i) + hash.repeat(j))
}
}