Javascript for Statement Question 3

Introduction

Write code using for loop to output the following shape:


shape:/*from   w  ww.  j av a  2s.co m*/

      #
     ##
    ###
   ####
  #####
 ######
#######



console.log("shape:");
function StairCase(n) {
    var s = '';
    for (var i = 1; i <= n; i++) {
            s += ' '.repeat(n - i) + '#'.repeat(i)  + '\n';
    }
    return s;
}
console.log(StairCase(7))



PreviousNext

Related