Timkor

firTreeOneLoop

Sep 24th, 2020 (edited)
1,241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let height = +prompt('enter tree height:')
  2.  
  3. for (let row = 0, stars = 1, space = height - 1;
  4.  row < height; row++, stars += 2, space -= 1) {
  5.     console.log(' '.repeat(space) + '*'.repeat(stars) + ' '.repeat(space) +
  6.       '" "=' + space + ' *=' + stars);
  7. }
  8. console.log(' '.repeat(height - 1) + '*') // foot
Add Comment
Please, Sign In to add comment