Skip to main content
2 of 3
edited body
CodeYogi
  • 5.1k
  • 12
  • 50
  • 104

Printing staircase revisited

What can be more elegant ways to solve the given problem.

    #
   ##
  ###
 ####

Code:

function StairCase(n) {
    for (var i = 1; i <= n; i++) {
        var col = i;
        for(var j = 1; j <= n - col; j++) {
            process.stdout.write(' ');
        }
        for(var j = 1; j <= col; j++) {
            process.stdout.write('#');
        }
        process.stdout.write('\n');
    }

}
CodeYogi
  • 5.1k
  • 12
  • 50
  • 104