Skip to content

Instantly share code, notes, and snippets.

@antenando
Created February 9, 2017 02:27
Show Gist options
  • Save antenando/fdd532e2a63c34ed501fccbb72508e59 to your computer and use it in GitHub Desktop.
Save antenando/fdd532e2a63c34ed501fccbb72508e59 to your computer and use it in GitHub Desktop.
function StairCase(n) {
var printLine = function(y, t){
var line = '';
for (var j = 0; j <= t; j++) {
if (j < y) {
line += ' ';
} else if (j > y){
line += '#';
}
}
return line;
};
var stair = '';
for (var i = n-1; i >= 0; i--) {
stair += printLine(i, n) + '\n';
}
return stair;
}
var stair = StairCase(32);
console.log(stair);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment