Skip to main content
Question Protected by Jamal
edited tags; edited tags
Link
200_success
  • 144.2k
  • 22
  • 188
  • 473
edited body
Source Link
CodeYogi
  • 5.1k
  • 12
  • 50
  • 104

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

    #
   ##
  ###
 ####

Code:

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

}

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

    #
   ##
  ###
 ####

Code:

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

}

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');
    }

}
Source Link
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 row = i;
        for(var j = 1; j <= n - row; j++) {
            process.stdout.write(' ');
        }
        for(var j = 1; j <= row; j++) {
            process.stdout.write('#');
        }
        process.stdout.write('\n');
    }

}