JSFiddle - React, Tailwind, and code Playground

JavaScript

/*Create a staircase based on user input n.

steps(5) should return the below output:
"#    "
"##   "
"###  "
"#### "
"#####" 
*/

const steps = (n) => {
if( n > 0){
  for (let row = 0; row < n; row++) {
      let step = '';

      for (let col = 0; col < n; col++) {
        col <= row ? step += '#' : step += ' ';
      }
       console.log(step);
   }
   return
}
console.log(`please give a number greater than 0`)
}

steps(5);
/* Output
"#    "
"##   "
"###  "
"#### "
"#####" */