1. from 0 to n (rows)
2. stair๋ผ๋ ๋น ๋ฌธ์์ด์ ๋ง๋ ๋ค
3. from 0 to n (colums)
4. column =< current row -> add # to 'stair'
5. else add space to 'stair'
6. console log 'stair'
function steps(n) {
for (let row = 0; row < n; row ++) {
let stair = '';
for (let column = 0; column <n; column++) {
if (column <= row) {
stair += '#';
} else {
stair += ' ';
}
}
console.log(stair)
}
}
function steps(n, row = 0, stair = '') {
if (n === row) {
return;
}
if (n === stair.length) {
console.log(stair);
return steps(n.row+1);
}
if(stair.length <= row) {
stair += '#'
} else {
stair += ' ';
}
steps (n, row, stair);
}
function steps(n, row = 0, stair = '') {
if (n === row) {
return;
}
if (n === stair.length) {
console.log(stair);
return steps(n.row+1);
}
const add = stair.length < = row ? '#' : ' ';
steps (n, row, stair+add);
}