DEV Community

Discussion on: Printing Staircase in JavaScript

Collapse
 
yajindragautam profile image
Yajindra Gautam • Edited

Great.
You can make even more shorter like this

for(let i = 0; i< n; i++){
          // print out a " " n-i times and append a # i times
      // console log adds a new line by default

      console.log(" ".repeat(n-i) + "#".repeat(i))
    }
Enter fullscreen mode Exit fullscreen mode