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

    #
   ##
  ###
 ####


Code:

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

}
JavaScript function names should start with a lowercase character, and "staircase" is one compound word in English.

Since every line is nearly the same, and only one character changes at a time, you should take advantage of that and use an array as a buffer.

function staircase(n) {
    var line = Array(n + 1).fill(' ');
    line[n] = '\n';
    for (var i = n - 1; i &gt;= 0; i--) {
        line[i] = '#';
        process.stdout.write(line.join(''));
    }
}