tree works with any height

This commit is contained in:
szabomarton 2024-09-10 11:11:52 +02:00
parent 37bfb70b36
commit d310e69a6c

View File

@ -1,12 +1,13 @@
let space = ' '; let space = ' ';
let star = '*'; let star = '*';
let bar = '|'; let bar = '|';
let magassag = 10;
let width = magassag * 2 - 1;
for (let i = 1; i < magassag + 1; i++){
for (let i = 1; i < 8; i++){
let starnum = i + i - 1; let starnum = i + i - 1;
let spacenum = (13 - starnum) / 2; let spacenum = (width - starnum) / 2;
let line = space.repeat(spacenum) + star.repeat(starnum) + space.repeat(spacenum); let line = space.repeat(spacenum) + star.repeat(starnum) + space.repeat(spacenum);
@ -14,7 +15,7 @@ for (let i = 1; i < 8; i++){
console.log(line); console.log(line);
} }
let spnum = (13 - 3) / 2; let spnum = (width - 3) / 2;
let barnum = 3; let barnum = 3;