Advertisement
audipower

christmasTree

Feb 22nd, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function exercise(input) {
  2.  
  3.     let n = Number(input.shift());
  4.     let result = "";
  5.    
  6.     for (var row = 1; row <= n; row++){
  7.         for (var k = 1; k <= n - row  + 1; k++){
  8.             result += " ";
  9.         }
  10.         for(var col = 1; col <= row; col++){
  11.             result += " " + "*";
  12.         }
  13.         result += "\n";
  14.     }
  15.     console.log(result);
  16.  
  17. }
  18.  
  19. exercise(["5"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement