Advertisement
informaticage

Reversed console tree

Jan 5th, 2021
922
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // *********** n
  2. //  *********  n - 2
  3. //   *******   n - 4
  4. //     ***     n - 8
  5. //      *      n - 10
  6.  
  7. let treeHeight = 10;
  8. treeHeight *= 2;
  9.  
  10. for (let troncoL = 0; troncoL < 3; troncoL++) {
  11.   let tronco = "";
  12.   for (let t = 0; t < treeHeight / 2 - 1; t++) tronco += " ";
  13.   tronco += "*";
  14.   console.log(tronco);
  15. }
  16.  
  17. for(let i = treeHeight; i > 0; i -= 2) {
  18.     let s = "";
  19.     for(let j = 0; j < (treeHeight - i) / 2; j++ ) {
  20.         s += " ";
  21.     }
  22.  
  23.     for(let j = 0; j < i - 1; j++) {
  24.         s += "*";
  25.     }
  26.     console.log(s);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement