JSFiddle - React, Tailwind, and code Playground
by Alexey
JavaScript
function steps(step) {
/* let x = step */
;
/* let c = ''
while (x > 0) {
c += 'x';
let diff = step - c.length;
let b = ''
for (let x = 0; x < diff; x++) {
b += ' '
}
console.log(`'${c}${b}'`);
x--;
} */
for (let row = 0; row < step; row++) {
let stair = '';
for (let column = 0; column < step; column++) {
if (column <= row) {
stair += '#';
} else {
stair += ' ';
}
}
console.log(stair);
}
}
steps(5)