The following is my solution to the Staircase problem. I’m using String.prototype.padStart to add the appropriate number of spaces in order to build the rises and making sure to right-align the steps. I also use String.repeat() to build the steps that make up the staircase.


Write a program that prints a staircase of size n. Where n is an integer.


  • 0 < n ≤ 100

Output Format

Print a staircase of size n using # symbols and spaces.

NOTE The last line must have 0 spaces in it.


function staircase (n) {
  for (let i = 1; i <= n; i++) {
    const step = '#'.repeat(i); // create a step
    const rise =, n, ' '); // Add necessary spaces


JS Bin